Skip to main content

Posts

Showing posts from June, 2013

Validating DropDownList using RequiredFieldValidator

In ASP.NET we need to validate DropDownList controls. But validating the DropDownList control with RequiredFieldValidator is not a straight forward as validating a TextBox control with RequiredFieldValidator. It requires little extra work. Following are the steps for validating a  DropDownList  with  RequiredFieldValidator Step 1: Create a DropDownList control 1: < asp:DropDownList ID ="ddlFruit" runat ="server" Height ="22px" Width ="200px" > 2: < asp:ListItem > - Select - </ asp:ListItem > 3: < asp:ListItem > Apple </ asp:ListItem > 4: < asp:ListItem > Orange </ asp:ListItem > 5: < asp:ListItem > Banana </ asp:ListItem > 6: < asp:ListItem > Pineapple </ asp:ListItem > 7: </ asp:DropDownList > Step 2: Add a RequiredFieldValidator 1: < asp:RequiredFieldValidator ID ="rfvFruit" runat =&q