My user control is as follows:
<asp:TextBox ID="_txtLeadDate" runat="server" ReadOnly="true">
</asp:TextBox>
<asp:CustomValidator ID="CustomValidator2" runat="server" ControlToValidate="_txtLeadDate" ErrorMessage="You cannot select a day earlier than today!" OnServerValidate="CustomValidator2_ServerValidate" SetFocusOnError="True">
</asp:CustomValidator>
and server side code:
protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args){
if (some condition){
args.IsValid = false;
}else{
args.IsValid = true;
}
}
But the page displays an error:
'ASP.usercontrol_preordercontrol_ascx' does not contain a definition for "CustomValidator2_ServerValidate", and the extension method "CustomValidator2_ServerValidate" cannot be found that accepts the first argument of the type "ASP.usercontrol_preordercontrol_ascx" (do you miss using the directive or using the link)
source
share