9 Answers, 1 is accepted
Please remove the
property from your Requiredfieldvalidator.
<telerik:RadDropDownList runat="server" ID="ddlPatients" Width="358px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="Patient ID is Required"
ControlToValidate="ddlPatients" runat="server" Text="<img src='../App_Themes/Images/exclamation.png' />"
If this is the very same implementation that you are using at your end, the RadDropDownList would be populated, with setting its first item as selected. In this case the validation would pass, because a PatientID is actually selected. If you want to push the user to select an item different from the first one, you could set the InitialValue property of the Required Field Validator and set first item's Text to the InitialValue property, like demonstrated in this video. Other possible implementation would be to set the DefaultMessage property of the RadDropDownList. Thus you would avoid preselecting the first item of the DropDownListItemsCollection, like demonstrated in this video.
I know this post have some time already. I was having the same issue with rad ddl and required field validators and your video help me out. But, what I realized is that there is something odd about required field validator, because, why is it called "InitialValue" if it is considering the Text of the dropdownlist item?
I was always using on my asp.net dropdownlists the Text="- Select -" and the Value="", so my first guess to solve my issue was to put InitialValue="" but it was not working. By checking your video l saw that it was expecting the Text "- Select -" to work properly.
Maybe the property should be called "InitialText" and not "InitialValue" what do you think?, or better: it should be checking the value property from dropdownlist and not the selected text.
Indeed, the naming convention could be differently interpreted and sometimes it could cause such misunderstanding. However, I am afraid that the asp:RequiredFieldValidator is not under our jurisdiction and we would have to accept it as it is.
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Required Field Validator works only after the button event has been triggered. Button Submit should not work if the two raddatepickers are empty. It works only after the button submit event has been completed. Please help.
<table style="margin-left: 30px; ">
<asp:Label ID="Label2" runat="server" Text="Date From:" Font-Size="12px"></asp:Label>
<telerik:RadDatePicker ID="txtFromDate" Runat="server" Visible="true" Font-Size="12px" MinDate="2015-01-01">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ForeColor="Red" ControlToValidate="txtFromDate" Display="Dynamic" EnableClientScript="false"></asp:RequiredFieldValidator>
<asp:Label ID="Label1" runat="server" Text="Date To:" Font-Size="12px"></asp:Label>
<telerik:RadDatePicker ID="txtToDate" Runat="server" Visible="true" Font-Size="12px" MinDate="2015-01-01">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ForeColor="Red" ControlToValidate="txtToDate" Display="Dynamic" EnableClientScript="false"></asp:RequiredFieldValidator>
<asp:Button runat="server" ID="btnSubmit" Text="SEARCH" CausesValidation="true" />
When the EnableClientScript property is set to false, the control validates after the post back. Setting it to true, the validation will kick in and prevent the post back if values are not present.