How to set Page.IsValid in ASP.Net

asp.net, validation

Solution

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="*" />

Problem

When the page class property `IsValid` is read only, how can I set it using my own validation method? So far all I've been able to do is set this property by calling `Page.Validate()`. How can I write my own functionality that will change the `IsValid` property just like `Page.Validate()`?

Original source