Hi all,
I have a asp.net form, inside has a webcombo, I placed a requiredfieldvalidator and want to validate it, but cannot choose the webcombo control inside the requirefieldvalidator.
Can you suggest me how to ensure user choose a value in webcombo before submit the form?
Thank you very much for your help! Happy new year!
Ah, for a CustomValidator ControlToValidate is not required or necessary:
<asp:CustomValidator ID="cvList" runat="server" ErrorMessage="List is a required field" EnableClientScript="False" Text="*" Enabled="True" OnServerValidate="cvList_ServerValidate"></asp:CustomValidator>
protected void cvList_ServerValidate_ServerValidate(object source, ServerValidateEventArgs e) {
//Check anything that is appropriate (note control does not have to be passed in)
if (iddlList.SelectedRow.Cells[1].Text != "M") { e.IsValid = false; } }
Thanks for your reply!
But I tried to place a customvalidator in the asp.net page. But in the customvalidator cannot chooose the webcombo in "ControlToValidate" value. Can you teach me how to make it work? Thanks!
The UltraWebCombo does not have the typical attribute of a control such as:
[ValidationProperty("DataValue")]
which enables a required field validator to work. In hindsight this makes sense because depending on your usage of the control (for instance, a user can type in free text) DisplayValue is correct versus DataValue. So, what you really want to do is use a custom validator on the webcombo. This gives you the latitude to interrogate whichever attribute is your (mental) appropriate Validation Property of interest.