简体   繁体   English

如何在ASP.NET 4.5中禁用对控件的验证

[英]How to disable validation on control in ASP.NET 4.5

Software : 软件

ASP.NET Application. ASP.NET应用程序。 Visual Studio 2013. Visual Studio 2013。

Scenario : 场景

I have three button: email , start project and clear . 我有三个按钮: 电子邮件启动项目清除 When I click on the start project button, it validates the user's input automatically. 当我单击开始项目按钮时,它会自动验证用户的输入。 When I click clear button, it should clear any user's input. 当我单击清除按钮时,它将清除任何用户的输入。

My problem is, when I click on the clear button, it is trying to validate the user's input. 我的问题是,当我单击清除按钮时,它正在尝试验证用户的输入。

Question : 问题

When I click on the clear button, How can I disable this validation & enable again when I click submit button? 单击清除按钮时,如何单击提交按钮如何禁用此验证并再次启用?

Code sample: 代码示例:

<input type="email"  runat="server" id="email"/>
<asp:Button ID="btnStartProject" runat="server" Text="Start project" 
            OnClick="btnStartProject_Click" />
<asp:Button ID="btnClear" runat="server" OnClick="btnClear_Click" Text="Clear" 
            EnableClientScript="False" 
            CausesValidation="False" />

(I am putting my comment as an answer for this case. It might be helpful for future readers) (我将自己的评论作为对此案的答案。这可能对将来的读者有所帮助)

It is not neccessary, to disable the validation on the email button by custom coding. 不必通过自定义编码来禁用对电子邮件按钮的验证。 Changing the input type of the clear button to reset has solved my problem: <input type="reset" value="Clear"/> 更改清除按钮的输入类型以进行reset已解决了我的问题: <input type="reset" value="Clear"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM