CustomValidator won't fire method
Hi,
I'm trying to use a CustomValidator to run a method to check whether a username is already in the database. I can't seem to get the method to fire though. Here's the tag for the component:
<asp:CustomValidator id="CustomValidator1" runat="server" CssClass="errorText" ForeColor=" " ErrorMessage="» Username already used" ControlToValidate="username" OnServerValidate="usernameValidate"></asp:CustomValidator>
and here's my code for usernameValidate:
public void usernameValidate(object source, ServerValidateEventArgs args)
{
if (BLUser.getInstance().getUser(username.Text) == null)
args.IsValid = true;
else
args.IsValid = false;
}
I've tried making the method set args.IsValid to false all the time but still doesn't work, doesn't look like the method is firing. I've also tried setting the OnServerValidate in the code behind but still doesn't work. Any ideas why?
Thanks
|