custom validator is not firing on the server side code

Sep 12 2019 6:25 AM
Hi Friends,
 
working on the cusom validator in aspx page and validation method from the server side writen but it not firing the method
 
aspx page
<td style="width: 25%; height: 21px" rowspan="1" colspan="1" style="border-collapse: collapse" class="br-td3">
<asp:TextBox ID="txtName" runat="server" MaxLength="30"></asp:TextBox>
<asp:CustomValidator ID="valName" runat="server"><img src="images/error.gif" /></asp:CustomValidator>
<asp:CustomValidator ID="valNamen" runat="server" Display="Dynamic" ForeColor="Red" ErrorMessage="" OnServerValidate="valNamen_ServerValidate"></asp:CustomValidator>
</td>
 
and in the server side written the code like this
protected void valNamen_ServerValidate(object source, ServerValidateEventArgs args)
{
if (txtName.Text == string.Empty)
{
valNamen.ErrorMessage = "Please enter Valid Name.";
args.IsValid = false;
}
}
 
but th method is not firing any time.
 
let us know if any thing i am missing here  
 

Brought to you by:

Answers (1)