Hi.
I am trying to validate a textbox using custom validator. If a specific radio button is checked and the textbox is empty, I want to display error. I used a custom validator with control-to-validate set to the textbox. In the server function, I check if radio button is checked and textbox is blank, set args.isvalid to false. However, when I trace it, the function is never hit. I have checked the properties and they are set properly (causes validation ,,,)
Any idea what might be wrong?
<asp:TextBox runat="server" ID="tbCoreFile" ReadOnly="true" Text="" /> (textbox gets populated dynamically)<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Error ... Error" ControlToValidate="tbCoreFile" ValidationGroup="vgGeneral" Display="Dynamic" Text="*" OnServerValidate="CustomValidator1_ServerValidate" />
protected
void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) {if ((rbl.SelectedIndex == 0) && (args.Value.ToString().Trim() == string.Empty))
args.IsValid =
false;
elseargs.IsValid = true;
}
Thanks,