问题与普通防爆pression验证在ASP.NET文本框 [英] Issue with Regular Expression Validator for text box in ASP.NET

查看:104
本文介绍了问题与普通防爆pression验证在ASP.NET文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林有我的code与RegularEx pressionValidator问题!

Im having issues with the RegularExpressionValidator in my code!

我有两个文本框在我的HTML页面,并在codeI有插入的参数数据库的SQL命令时,问题是,如果我把一个特殊字符的文本框中输入SQL停止,因为我需要验证,所以我尝试验证这个样子。

I have 2 text boxes in my html page and in the code i have the sql command that inserts the parameters to the DB, the issue is that if i put a special character to the text box the sql stops because i need the validators, so i tried validating like this.

Insert the files number.
<asp:TextBox ID="TextBox1" runat="server" MaxLength="10" ></asp:TextBox>

Whats the users Name <br />
<asp:TextBox ID="TextBox2" runat="server" MaxLength="10"></asp:TextBox>

验证器定义为:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
    ErrorMessage="RegularExpressionValidator" ValidationExpression="^\d+$" 
    ControlToValidate="TextBox1"></asp:RegularExpressionValidator>

但是,当加载它忽略我的验证前presion公司。

But when loading it ignores my validation expresion.

请缺什么。

感谢

推荐答案

我检查的一切,终于得偿所愿,

I checked everything and finally got it,

我不得不添加到我的的web.config 以下内容:

I had to add to my web.config the following:

<configuration>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
</configuration>

这解决了我的问题。

And that solved my issues

这篇关于问题与普通防爆pression验证在ASP.NET文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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