Introduction: In this article today I will explain how we can Validate Listbox
using Require filed validator
control in asp.net 
|  | 
| Click here to Enlarge | 
Description: 
 In the previous article I have explained Show Gridview row detail in Tooltip on mousehover using Jquery in asp.net;Fill dropdownlist with days, month and year in asp.net,Server side validation in MVC Razor using data annotation,Like linq query example and bind gridview,Create a dynamic Slider in asp.net, URL routing in asp.net website and Validate Dropdownlist using Require filed validator control in asp.net.
Example:
Add a webform to
project. Drag and drop the Listbox control from toolbox to webform.
<center>
    <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:ListBox>
       </br>                
               
<asp:RequiredFieldValidator
ID="rfvlstboxcountry"
            ControlToValidate="lstboxcountry"
InitialValue="0"
runat="server"
            ErrorMessage="Please
select Country" ForeColor="#FF3300"></asp:RequiredFieldValidator>
        </fieldset>
        </center>
Note: If not want “—Select
Country—“ option then set the InitialValue="".
Build and run the
project.
 
 
.png) 

Hi theгe, thiѕ weekend is pleаsant in favor of me, as this
ReplyDeletetime i am reading tthіs fantastic iformative paragraph here aat my
home.
my blog - equities trader salary