My page is a registration page, where a user enters a username, e-mail address and password. Here is my code behind:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRegister_Click(object sender, EventArgs e)
{
if (!Page.IsValid)
return;
}
protected void cvEmail_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
}
Here is my page:
<asp:ValidationSummary ID="vs" runat="server" />
<asp:TextBox ID="txtUsername" runat="server" />
<asp:TextBox ID="txtEmail" runat="server" />
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" />
<asp:Button ID="btnRegister" runat="server" OnClick="btnRegister_Click" />
<asp:CustomValidator ID="cvEmail" runat="server" ControlToValidate="txtEmail"
OnServerValidate="cvEmail_ServerValidate"
ErrorMessage="Invalid Email" />
So the problem is that if custom validator fails, when the page reloads with my error message, my textboxes are empty. But the weird thing is that if I inspect the textbox elements in Firebug, the value
of the input
is set, it's just not showing up on the page for some reason.
I've tried setting EnableViewState
to true on the textbox and on the page, and that didn't help.
Anyone know what I'm doing wrong?