title: Asp.net and Ext.Net validation
body: <p>Does anybody show me an example of ext.net validation? I want to mix asp.net and ext.net validation. Or use ext.net validation only.</p>
  
  <p>I've already saw these examples <a href="http://examples.ext.net/#/Form/Validation/Custom_VType/" rel="nofollow">http://examples.ext.net/#/Form/Validation/Custom_VType/</a> and <a href="http://examples.ext.net/#/Form/FormPanel/Validation/" rel="nofollow">http://examples.ext.net/#/Form/FormPanel/Validation/</a> but it's not enough.</p>
  
  <p>Also, I wonder why the code bottom doesn't work. It throws an exception </p>
  
  <blockquote>
    <p>"Page.IsValid cannot be called before validation has taken place. It
    should be queried in the event handler for a control that has
    CausesValidation=True and initiated the postback, or after a call to
    Page.Validate"</p>
  </blockquote>
  
  <pre><code>&lt;script runat="server"&gt;
  
          void Button_Click(object sender, EventArgs e) {
              // Display whether the page passed validation.
              if (Page.IsValid) {
                  Label1.Text = "Page is valid.";
              }
              else {
                  Label1.Text = "Page is not valid!";
              }
          }
  
          void ServerValidation(object source, ServerValidateEventArgs args) {
              try {
                  // Test whether the value entered into the text box is even.
                  int i = int.Parse(args.Value);
                  args.IsValid = ((i % 2) == 0);
              }
              catch (Exception ex) {
                  args.IsValid = false;
              }
          }
  
      &lt;/script&gt;
      &lt;ext:Label ID="Label1" runat="server" Text="Enter an even number:" /&gt;
      &lt;br /&gt;
      &lt;ext:TextField ID="TextField1" runat="server" /&gt;
      &lt;asp:CustomValidator runat="server" ControlToValidate="TextField1" OnServerValidate="ServerValidation"
          ErrorMessage="Not an even number!" /&gt;
      &lt;ext:Button runat="server" Text="Validate" &gt;
          &lt;DirectEvents&gt;
              &lt;Click OnEvent="Button_Click" /&gt;
          &lt;/DirectEvents&gt;
      &lt;/ext:Button&gt;
  </code></pre>