title: CustomValidator control not working in .Net
body: <p>I have a rather large ASPX form with lots of textboxes and drop down lists to fill in.  Most of the textboxes have RequiredFieldValidator controls and these work just fine.</p>
  
  <p>However, I have 3 textboxes for Home, Mobile and Work Telephone numbers.  Each textbox is optional but if it is filled in, then the value must be numeric.  I don't need to validate the format of the phone number at this point, only ensure that it is numeric.</p>
  
  <p>The client side code for one of the fields looks like so:</p>
  
  <pre><code>&lt;asp:Label ID="lblWorkPhone" runat="server" AssociatedControlID="txtWorkPhone" Text="&lt;%$ Resources: Registration, WorkPhone %&gt;" /&gt;&lt;br /&gt;
  &lt;asp:TextBox ID="txtWorkPhone" runat="server" /&gt;
  &lt;asp:CustomValidator ID="validateWorkPhone" runat="server" 
                              ValidationGroup="reg" ControlToValidate="txtWorkPhone" ForeColor="Red" 
                              ErrorMessage="&lt;%$ Resources: Registration, HomePhoneNumber %&gt;" 
                              Text="&lt;%$ Resources: Registration, RequireMessage %&gt;" 
                              onservervalidate="validateWorkPhone_ServerValidate" /&gt;
  </code></pre>
  
  <p>The server side validation method is here :</p>
  
  <pre><code>protected void validateWorkPhone_ServerValidate(object source, ServerValidateEventArgs args)
  {
      long temp = 0;
  
      long.TryParse(txtWorkPhone.Text, out temp);
  
      if (temp == 0)
      {
          args.IsValid = false;
          validateWorkPhone.IsValid = true;
      }
      else
      {
          args.IsValid = true;
          validateWorkPhone.IsValid = false;
      }
  }
  </code></pre>
  
  <p>As far as I can tell the server side validation method is not firing at all.  All the other validation controls on the page do seem to work fine.</p>
  
  <p>Can anybody help?</p>