I have a custom control included in a form that includes a dropdown list. The form has a number of other required fields, so i was wondering how to validate this dropdown.
<gaia:TextBox ID="TitleTextBox" runat="server"/>
<gaia:RequiredFieldValidator runat="server" ControlToValidate="TitleTextBox"
ErrorMessage="Please fill in the press release title" Text="*" Display="None" ValidationGroup="save" />
<CN:ProductCategoryDropDown runat="server" ID="ProductCategoryDropDown" />
<gaia:CustomValidator runat="server" ID="ProductCategoryValidator" OnServerValidate="ProductCategory_Validate" ValidationGroup="save"
Display="None" Text="*" ErrorMessage="Please select a category" />
the code behind looks like this
protected void ProductCategory_Validate(object source, ServerValidateEventArgs args)
{
args.IsValid = (ProductCategoryDropDown.SelectedValue>0);
}
On the customvalidator above, I purposely left out the 'ControlToValidate' because it throws an error.
Please help.