Saturday 21 April 2012

Comment Application Asp.Net Using C#

1.First Step    :
Drag and Drop TextBox in Design Phase

2.Second Step:
Right Click on TextBox , Click on Properties Change the TextMode = MultiLine

3.Third Step   :
Drag and Drop Button in Design Phase from Tool Box

4.Fourth Step  :
Double Click on Button ,Its Move to Code file ..

....................Code for Comment.................
Using System.Data.SqlClient;

void button1_click(Event_Handler)
{
string comment=textbox1.Text;

string strcon=ConfigurationManager.Connectionstring["New of Connection String"].tostring();
SqlConnetion con=new SqlConnection(constr);

string strcmd="Insert Into Comment(comment) values(@comment)";
SqlCommand cmd=New SqlCommand();
cmd.CommandText=cmdstr;

cmd.Parameters.AddWithValue("@comment",comment);
cmd.Connection=con;

con.Open();
Int result=Convert.ToInt32(cmd.ExecuteScalar());
if(result==1)
{
Response.Redirect("Default1.asp");
}
}

1 comment: