Hello,
I've implemented a requiredfieldvalidator for a radcombobox which works fine on submitting the form, however I would like to show the red asterisk before the page is submitted to indicate to the user that the field is required. Using
The combobox si bound to a list with the first item having the text of [Select...] before the Page.Validate is called:
Note that the actual validation on submit works fine, it's just the ability to pre-trigger the red asterisk that would be great.
Thanks
Jonathan
I've implemented a requiredfieldvalidator for a radcombobox which works fine on submitting the form, however I would like to show the red asterisk before the page is submitted to indicate to the user that the field is required. Using
Page.Validate();
in the Page_load event on the server activates the required field validators that are defined against text boxes, but I can't get the validator associated with the combobox to show.
<
table
>
<
tr
>
<
td
><
telerik:RadComboBox
id
=
"ddlCostCategory"
DataTextField
=
"Name"
DataValueField
=
"ID"
runat
=
"server"
SkinID
=
"WideDll"
></
telerik:RadComboBox
></
td
>
<
td
><
asp:RequiredFieldValidator
runat
=
"server"
ControlToValidate
=
"ddlCostCategory"
ID
=
"reqValCostCategory"
Text
=
"*"
ErrorMessage
=
"Cost Category is required"
InitialValue
=
"[Select...]"
></
asp:RequiredFieldValidator
></
td
>
</
tr
>
</
table
>
The combobox si bound to a list with the first item having the text of [Select...] before the Page.Validate is called:
var query2 = from c
in
PNGC_SmartGridContext.CostCategories select c;
IList<CostCategory> _costCategories = query2.ToList<CostCategory>();
_costCategories.Insert(0,
new
CostCategory() { ID = 0, Name =
"[Select...]"
});
ddlCostCategory.DataSource = _costCategories;
ddlCostCategory.DataBind();
Note that the actual validation on submit works fine, it's just the ability to pre-trigger the red asterisk that would be great.
Thanks
Jonathan