Customer Validation ASP.Net C#
<p>I am having the same problem as someone else in this forum.  My validation control is not firing...and not sure where I have gone wrong.  Could someone please take a look and let me know what obvious error I have here...thanks</p>

<p>I have set up a customer validator in my aspx page using the following:</p>

<pre><code>       &lt;asp:TextBox ID="EmployeeNumber2TextBox" runat="server"
 Text='&lt;%# Bind("EmployeeNumber") %&gt;'Visible='&lt;%# AllowEmployeeNumberEdit() %&gt;' /&gt;

           &lt;asp:CustomValidator ID="ValidateEmpNumber" runat="server" 
onservervalidate="ValidateEmpNumber_ServerValidate" 
    controltovalidate="EmployeeNumber2TextBox" 
    ErrorMessage="You Must Enter an Employee Number" Text="*" /&gt;
</code></pre>

<p>and the code behind:</p>

<pre><code>  protected void ValidateEmpNumber_ServerValidate(object sender, System.Web.UI.WebControls.ServerValidateEventArgs e)
  {
      int SiteCompanyID = System.Convert.ToInt32(Session["SiteCompanyID"]);
      SiteCompanyBLL SiteCompany = new SiteCompanyBLL();
      SiteCompanyDAL.SiteCompanyRow ScRow = SiteCompany.GetCompanyByID(SiteCompanyID);
      bool AutoGenerate = ScRow.AutoGenNumber;  // result returning true or false
      if (AutoGenerate == false)
      {
          if (e.Value.Length == 0)
          e.IsValid = false;
      else
          e.IsValid = false;
      }
  }
</code></pre>
