I have the following html:
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolder1" Runat="Server">
<form id="Form1" runat="server">
<table style="width:100%;">
<tr>
<td valign="top">
Message Content (text only)
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
ControlToValidate="tbContent"
runat="server"
Display="Dynamic"
ErrorMessage="REQUIRED" />
<asp:CustomValidator ID="CustomValidator1"
ControlToValidate="tbContent"
runat="server"
EnableClientScript="false"
OnServerValidate="validate_Content"
ValidateEmptyText="true"
ErrorMessage="INVALID"
Display="Dynamic" />
</td>
<td>
<asp:TextBox ID="tbContent"
runat="server"
style="resize:none;"
Width="98%"
Height="20em"
TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
</table>
<asp:Button ID="ButtonSubmit"
Text="Submit"
runat="server"
CausesValidation="true"
OnClick="click_Submit" ></asp:Button>
</form>
</asp:Content>
And the following code-behind:
protected void click_Submit(object sender, EventArgs args)
{
Page.Validate();
if (Page.IsValid)
{
}
else
{
}
}
protected void validate_Content(object sender, ServerValidateEventArgs e)
{
e.IsValid = (e.Value.Length >= 30);
}
The
CustomValidator
is not validating. I added the RequiredFieldValidator just to make sure the validators were working at all. Please note the following:
0) I do NOT want to validate on the client side, so don't bother suggesting it.
1) The
RequiredFieldValidator
is in fact working as you would expect.
2) I am fully aware of the fact that the
ValidateEmptyText
property is supposed to eliminate the need for the
RequiredFieldValidator
, but as I said, the
CustomValidator
event doesn't appear to fire.
3) I already tried not specifying a control to validate, and it STILL doesn't fire.
I'm at a loss. I've tried everything I found on google that I thought was applicable, and nothing has changed the result.
EDIT =======================
Still looking for an answer to this.