i am using update panel . a textbox is inside the update panel , still page is refreshed when text of textbox is chaned .
code behind is
protected void chkName(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(TextBox1.Text))
{
con = new SqlConnection(str);
con.Open();
cmd = new SqlCommand("select Name from info where Name=@1", con);
cmd.Parameters.AddWithValue("@1", TextBox1.Text);
SqlDataReader dbr = cmd.ExecuteReader();
if (dbr.HasRows)
{
checkusername.Visible = true;
imgstatus.ImageUrl = "del.gif";
lblStatus.Text = "UserName Already Taken";
System.Threading.Thread.Sleep(2000);
}
else
{
checkusername.Visible = true;
imgstatus.ImageUrl = "available.gif";
lblStatus.Text = "UserName Available";
System.Threading.Thread.Sleep(2000);
}
}
else
{
checkusername.Visible = false;
}
}
Sanjeeb LenkaPosted Aug 30, 2013, 1:08 AM
put your total table within updatepanel and check.
try below code: