如何绕过验证在ASP.NET按钮? [英] How to bypass validation for a button in ASP.NET?
问题描述
我有一个ASP.NET的形式,需要从用户输入。有一个在表单上提交
按钮和一个名为计算器
按钮,做了计算,以填充文本字段。我遇到的问题是,在表单上我有一组<的; ASP:的RequiredFieldValidator>
验证,当计算器
按钮被按下的形式得到确认。我不想当按下计算器
按钮,仅提交
按钮进行验证所需的字段。解决这个办法?
I have an ASP.NET form that takes input from a user. There's a Submit
button on the form and a button called Calc
which does a calculation to populate a text field. The problem I'm having is that on the form I have a set of <ASP:REQUIREDFIELDVALIDATOR>
validators and when the Calc
button is pressed the form gets validated. I don't want the required fields to be validated when the Calc
button is pressed, only the Submit
button. Any way around this?
推荐答案
将的CausesValidation
属性设置为false。
Set the CausesValidation
property to false.
这篇关于如何绕过验证在ASP.NET按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!