RegularExpressionValidator.IsValid==true
RegularExpressionValidator验证过表达式是错误的,提示也跳出来了,而这句RegularExpressionValidator.IsValid==true竟然还是true;这是为什么呢?给位大侠帮帮忙。代码如下,有提示错误跳出来,数据库验证提示邮箱可用?真搞不懂。
  if (RegularExpressionValidator2.IsValid==true)
         {
             Label2.Text = "恭喜你,该邮箱可用!";
             string connectingString = WebConfigurationManager.ConnectionStrings["register"].ConnectionString;
             SqlConnection con = new SqlConnection(connectingString);
             try
             {
                 con.Open();
                 SqlCommand cmd = new SqlCommand("select [Email] from [Register] where [Email]='"+txtEmail.Text+"'", con);
                 SqlDataReader reader = cmd.ExecuteReader();
                 if (reader.Read() == true )
                 {
                     Label2.Text = "该邮箱已经注册过,请输入一个邮箱";
                 }
             }
             catch (Exception err)
             {
                 Label1.Text=err.Message;
             }
             finally
             {
                 con.Close();
             }
         }
------解决方案--------------------在这前加一句
Page.Validate();