Hi folks...a truly frustrating problem!!
Have a custom validator that just does not call the server validation function but it does call a clientside function if i add the tag. To check it was not something i had done to the control or layout i added a data-type check as another validator immediately under:
<asp:CustomValidator ID="CustomValidatorPO" runat="server" ErrorMessage="If specified, it must be numeric and between 5 and 6 digits in length." ControlToValidate="txtPreviousOrder"
Text="If specified, it must be numeric" OnServerValidate="CustomValidatorPO_ServerValidate" Display="Dynamic" SetFocusOnError="true" CssClass="validator"></asp:CustomValidator><asp:CompareValidator ID="CompareValidatorPO" runat="server" ControlToValidate="txtPreviousOrder"
ErrorMessage="Enter Numerical Value" Operator="DataTypeCheck" Type="Double" ValidationGroup="submitquote"
SetFocusOnError="true" CssClass="validator" Display="Dynamic" />The data-type validator works fine but the custom validator procedure never calls the server side validator (i put a break point in and it never gets hit), the code which for reference is:
protected void CustomValidatorPO_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
//This is base class property used for debug
//ErrMSG = "";
//check for zero length first
string sOrderNumber = args.Value.ToString();
if (sOrderNumber.Length == 0)
{
args.IsValid = true;
return;
}
//check if numeric and correct length
try
{
int OrderNumber = int.Parse(args.Value);
if (OrderNumber > 0 && (OrderNumber.ToString().Length > 5 && OrderNumber.ToString().Length <= 6))
{
args.IsValid = true;
}
else
{
ErrMSG = "If specified, it must be numeric and between 5 and 6 digits in length.";
args.IsValid = false;
}
}
catch (Exception Ex)
{
ErrMSG = "Invalid value - unable to interpret as numeric code: "+Ex.Message;
args.IsValid = false;
}
} If i comment the function out it complains it is not there so why is it not executing??