asp.net中的RegularExpression Validator在localhost中工作,而不是在webhost中 [英] RegularExpression Validator in asp.net working in localhost not in webhost

查看:63
本文介绍了asp.net中的RegularExpression Validator在localhost中工作,而不是在webhost中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中使用了正则表达式验证器进行电子邮件验证。它完全在localhost中工作,但在服务器上传页面后,正则表达式验证器无法正常工作。在将详细信息保存到数据库后,它显示无效的电子邮件ID。请帮助



i have used regular expression validator in asp.net for email validation. it is working in localhost perfectly but after upload the pages in server, regular expression validator is not working.after saving the details into database it shows "invalid email id". pls help

<asp:TextBox ID="txtEmailid" runat="server" Width="180px" BorderColor="Black"

                                                             BorderStyle="Solid" BorderWidth="1px">
                                                         <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"                                                       ControlToValidate="txtEmailid" ErrorMessage="Invalid" ForeColor="#F04E23"

                                                             ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">





代码背后





Code Behind

protected void btnsave_Click(object sender, EventArgs e)
   {
       Page.Validate();


     if (txtMobileNo.Text == "")
       {
           lblErr.Text = "Enter the Mobile No";
           txtMobileNo.Focus();
           return;

       }
       else if (txtPhoneNo.Text == "")
       {
           lblErr.Text = "Enter the Phone No";
           txtPhoneNo.Focus();
           return;
       }
       else if (txtFax.Text == "")
       {
           lblErr.Text = "Enter the Fax No";
           txtFax.Focus();
           return;
       }
       else if (txtEmailid.Text == "")
       {
           lblErr.Text = "Enter the Email Id";
           txtEmailid.Focus();
           return;
       }

       else if (txtAddress.Text == "")
       {
           lblErr.Text = "Enter the Address ";
           txtAddress.Focus();
           return;
       }


       else
       {

               sales.Save();
               lblErr.Text = "Details Saved Successfully";
               GridBindData();
               Clear();

           }


   }

推荐答案

验证控件在客户端使用javascript或其他东西。



您应该创建一个称为表单或类似的验证组,并将验证组属性添加到文本框中,验证控制和提交按钮,并将原因验证添加到提交按钮。



在后面的代码中,我认为是,我用VB编写,所以它CS中有点不同



如果Page.validation那么



结束如果



清除浏览器缓存并进行测试。检查服务器上的asp.net版本,它可能已经过时,或者IIS Web服务器可能必须重新启动,它可能是缓存html,缓存没有更新。
The validation control uses javascript or something on the client side.

You should make a validation group, called form or something, and add the validation group attribute to the textbox, validation control and submit button, and add causes validation to the submit button.

On the code behind, I think it''s, I write in VB, so it''s a little different in CS

If Page.validation then

end if

Clear your browser cache and test it. Check your version of asp.net on the server, it may be out of date, or IIS web server may have to be restarted, it may be caching html, and the cache didn''t update.


这篇关于asp.net中的RegularExpression Validator在localhost中工作,而不是在webhost中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆