Vishwakant Tripathi

Vishwakant Tripathi

  • 1k
  • 721
  • 839.7k

Dropdownlist Validation with RequiredFieldValidator

Aug 17 2016 3:35 AM
I have one Dropdownlist to be validated by RequiredFieldValidator. And It has OnSelectedIndexChanged event so I have set AutoPostBack=true.(That is required because this dropdownlist will fill another dropdownlist on selection index changed).
I have set InitialValue="-1" that is first item as "--Select--". As I click on submit button it reload the page and then it shows error message.

 This is my controls.... 
 
<asp:DropDownList ID="ddlMsgSubCategories" runat="server" Width="320px" AutoPostBack="True" CausesValidation="True" OnSelectedIndexChanged="ddlMsgSubCategories_SelectedIndexChanged" CssClass="fontStandardInput"></asp:DropDownList><br />
 
<asp:RequiredFieldValidator runat="server" ID="rfvMsgSubCategories" ControlToValidate="ddlMsgSubCategories" Display="Dynamic" CssClass="fontValidation" InitialValue="-1" SetFocusOnError="true"></asp:RequiredFieldValidator>
 
 
 
Is there any option  that can be used to validate dropdownlist without reloading page.
 
Thanks.
Vishwakant. 
 

Answers (6)