vishal mewara

vishal mewara

  • NA
  • 12
  • 34.4k

How to Validate Drop Down List

Mar 20 2014 1:15 PM
<td style="width: 712px; text-align: left; margin:10px; height: 50px;">
<asp:DropDownList ID="DropDownListNewEmployeeRegisterationFormStates" runat="server" Width="226px" Height="33px" OnSelectedIndexChanged="DropDownListNewEmployeeRegisterationFormStates_SelectedIndexChanged" AutoPostBack="true" DataTextField="StateNames" DataValueField="StateID">
</asp:DropDownList>
</td>
<td style="width: 45%; text-align: left; height: 50px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidatorNewEmployeeRegisterationFormStates" runat="server" ControlToValidate="DropDownListNewEmployeeRegisterationFormStates" InitialValue="0" ErrorMessage="Please Select State Name" ForeColor="Red" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="width: 20%; text-align: left; height: 50px;"><h3>City of Resident : </h3></td>
<td style="width: 712px; text-align: left;margin:10px; height: 50px;">
<asp:DropDownList ID="DropDownListNewEmployeeRegisterationFormCity" runat="server" Width="225px" Height="28px" OnSelectedIndexChanged="DropDownListNewEmployeeRegisterationFormCity_SelectedIndexChanged" AutoPostBack="true" DataTextField="CityNames" DataValueField="CityID">
</asp:DropDownList>
</td>
<td style="width: 45%; text-align: left; height: 50px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidatorNewEmployeeRegisterationFormCity" runat="server" ControlToValidate="DropDownListNewEmployeeRegisterationFormCity" InitialValue="0" ErrorMessage="Please Select City Name" ForeColor="Red" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
</td>

Answers (2)