标签:style blog http io color ar os 使用 sp
学习完了牛腩之后,在进行ASP.NET的学习的时候,对所有学的知识,都有一种似曾相识的感觉,"哦,这个,在牛腩新闻发布系统中用过",只不过那时候,用的也是迷迷糊糊的,就说验证控件的使用吧,牛腩老师在验证码错误,密码,用户名错误均用到了验证控件,只不过那时候,只是迷迷糊糊跟着用了,现在有一种拨开云雾见月明的感觉。
protected void CustomValidator1_ServerValidate(object source,ServerValidateEventArgs args)
{
string userName = args.Value;
SqlConnection con = new SqlConnection("server=刘颖-PC;database=login;uid=sa; pwd=123456;");
con.Open();
SqlCommand cmd=new SqlCommand("select count(*) from login whereuserName='"+userName+"'",con);
intcount=Convert.ToInt32(cmd.ExecuteScalar());
if(count > 0)
{
args.IsValid=false ;
}
else
{
args.IsValid = true ;
}
con.Close();
}怎么样,验证控件的功能很强大吧!比我们之前输出MessageBox提示用户输入信息有误,简单又美观吧!
标签:style blog http io color ar os 使用 sp
原文地址:http://blog.csdn.net/tgbsqliuying/article/details/40952051