知道导致回发的控件是否导致通过Javascript进行验证 [英] Know if the control causing postback causes validation from Javascript
问题描述
我正在制作需要验证的Asp.Net页面.
如果某些验证由c#完成,则必须使用自定义验证来完成,因此会导致回发,这对于项目来说是不希望的.
因此,我使用Java脚本做到了这一点,但是现在即使任何控件引起回发,这些验证也会发生.
因此,有一种方法可以检查导致提交的控件是否应该在页面的commit()事件(即Java脚本)上引起验证.
请帮忙
谢谢
Hi,
I am making an Asp.Net page that requires validation.
Some of the validations if done by c# will have to be done using custom validations, hence causing Post-back and is not desirable for the project.
So I did that with java-script but now these validations occur even when any control causes post-back.
So is there a way to check if the control that caused submit, is supposed to cause validation, on submit() event of the page(i.e. Java-script).
Please help
Thanks
推荐答案
示例您具有按钮ABC和XYZ,并且具有文本框QWE.
您需要指定ValidationGroup.
可以说:
Example you have button ABC and XYZ and you have Textbox QWE.
You need to specify ValidationGroup.
Let say:
<asp:textbox id="QWE" runat="server" validationgroup="Q"></asp:TextBox>
<asp:Button id="ABC" runat="server" validationgroup="Q"></asp:Button>
<asp:Button id="XYZ" runat="server"> </asp:Button>
或者您可以通过将属性设置为
来简单地关闭XYZ按钮的验证
or you can simply turnoff the validation of the XYZ button by setting the attribute to
CausesValidation='false'
这篇关于知道导致回发的控件是否导致通过Javascript进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!