Thursday, July 17, 2014

Validate Listbox using Require filed validator control in

Introduction: In this article today I will explain how we can Validate Listbox using Require filed validator control in 

Validate Listbox
Click here to Enlarge


Add a webform to project. Drag and drop the Listbox control from toolbox to webform.
    <fieldset style="width:30%;height:100px">
    <legend>Validate Listbox using Requirefield validator control</legend>
       Please Select Country : <asp:ListBox runat="server" ID="lstboxcountry" Width="35%">
        <asp:ListItem Value="0">--Select Country--</asp:ListItem>
       <asp:ListItem Value="1">India</asp:ListItem>
 <asp:ListItem Value="2">China</asp:ListItem>
 <asp:ListItem Value="3">Russia</asp:ListItem>
 <asp:ListItem Value="4">Cuba</asp:ListItem>
 <asp:ListItem Value="5">Iran</asp:ListItem>
 <asp:ListItem Value="6">Brazil</asp:ListItem>
 <asp:ListItem Value="7">Sri lanka</asp:ListItem>
                <asp:RequiredFieldValidator ID="rfvlstboxcountry"
            ControlToValidate="lstboxcountry" InitialValue="0" runat="server"
            ErrorMessage="Please select Country" ForeColor="#FF3300"></asp:RequiredFieldValidator>

Note: If not want “—Select Country—“ option then set the InitialValue="".
Build and run the project.

Is this article helpful for you?

If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email. 

1 comment:

  1. Hi theгe, thiѕ weekend is pleаsant in favor of me, as this
    time i am reading tthіs fantastic iformative paragraph here aat my

    my blog - equities trader salary