如何设置Page.IsValid在ASP.Net [英] How to set Page.IsValid in ASP.Net
问题描述
在页面类属性为只读的IsValid
,我怎么能使用我自己的验证方法?集
When the page class property IsValid
is read only, how can I set it using my own validation method?
到目前为止,所有我已经能够做的就是通过调用设置该属性 Page.Validate()
。
So far all I've been able to do is set this property by calling Page.Validate()
.
我怎么能写我自己的功能,这将改变的IsValid
属性就像 Page.Validate()
?
How can I write my own functionality that will change the IsValid
property just like Page.Validate()
?
推荐答案
您没有设置的IsValid ,而不是直接调用的验证()在的方法页对象。如果您有自定义的验证方法,那么你需要使用的CustomValidator 对象,并设置该功能在服务器端验证属性。
You don't set IsValid directly instead you call Validate() method of the Page object. If you have your custom validation methods then you need to use CustomValidator object and set that function in its server side validation property.
<asp:CustomValidator ID="YourValidator" runat="server" SetFocusOnError="true"
ControlToValidate="YourControl"
ClientValidationFunction="YOUR_JAVASCRIPT_FUNCTION"
OnServerValidate="YOUR_SERVER_VALIDATION_FUNCTION" Text="*" />
这篇关于如何设置Page.IsValid在ASP.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!