Required Field validator with DropDownList in .net

  <asp:DropDownList id="DropDownList1" runat="server"
            ontextchanged="DropDownList1_TextChanged">
   <asp:ListItem Selected="True">Select a profession</asp:ListItem>
   <asp:ListItem>Programmer</asp:ListItem>
   <asp:ListItem>Lawyer</asp:ListItem>
   <asp:ListItem>Doctor</asp:ListItem>
   <asp:ListItem>Artist</asp:ListItem>
</asp:DropDownList>
 
<asp:RequiredFieldValidator id="RequiredFieldValidator1"  
  runat="server" ErrorMessage="Please make a selection"
  ControlToValidate="DropDownList1"
  InitialValue="Select a profession">
</asp:RequiredFieldValidator>
Ebook Download
View all
Learn
View all