简体   繁体   English

如何取消customvalidators动作?

[英]how to cancel customvalidators action?

I have a webform with a textbox and 3 buttons (add, save and cancel), I'm learning how to use customvalidators (ASP.NET 4.0). 我有一个带有文本框和3个按钮(添加,保存和取消)的Web窗体,我正在学习如何使用customvalidators(ASP.NET 4.0)。

Once the page is loaded, you can only see the add button, after you click on it you can see the textbox and the other 2 buttons. 页面加载后,您只能看到添加按钮,单击后可以看到文本框和其他两个按钮。

If textbox is empty I can't save the record (I get this done successfully with customvalidator and javascript, it shows me the error message "textbox can not be left empty"), but what happens if I don't want to save the record anymore and want to cancel instead (by clicking on the cancel button while textbox is still empty)? 如果文本框为空,则无法保存记录(我使用customvalidator和javascript成功完成了该操作,它显示了错误消息“文本框不能为空”),但是如果我不想保存该记录,会发生什么情况记录下来并想要取消(通过在文本框仍然为空时单击“取消”按钮)吗?

I get the customvalidator error "textbox can not be left empty". 我收到customvalidator错误“文本框不能留空”。 I have to type something i it so I can do what i need. 我必须输入一些内容,这样我才能做我需要的事情。

Any suggestions? 有什么建议么? Thanks in advance 提前致谢

For Cancel button set the attribute CausesValidation="false" . 对于“取消”按钮,设置属性CausesValidation =“ false” That is it... 这就对了...

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

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