CustomValidator1_ServerValidate是干什么的? 在什么情况下触发该事件?
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
string str = ConfigurationSettings.AppSettings[ "dm "];
SqlConnection conn = new SqlConnection(str);
conn.Open();
string strselect= "select * from users where user_yonghu= ' "+TextBox1.Text+ " ' ";
SqlCommand comm = new SqlCommand(strselect, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
{
CustomValidator1.IsValid = false;
}
else
{
CustomValidator1.IsValid = true;
}
conn.Close();
}
这段代码是什么意思?
------解决方案--------------------是控件在检验的时候连到服务器看是否符合规格