Sponsored Ad

Thursday, July 1, 2010

How to Check for Selected Value in DropDownList using ASP.NET | RequiredFieldValidator

Now you can veryfy for selcted value in combobox using asp.net control RequiredFieldValidator. This control verifys for values at client side. So you just need to assign name of combobox in validation control and all id done.

 

How to Check for Selected Value in DropDownList using ASP.NET | RequiredFieldValidator

How to Check for Selected Value in DropDownList using ASP.NET | RequiredFieldValidator

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html>
<body>
    <form id="Form1" runat="server">
        <h4>
            Check for Selected Value</h4>
        <br />
        Select a Value:    
        <asp:DropDownList ID="DropDownList1" runat="server">
         <asp:ListItem></asp:ListItem>
        <asp:ListItem>Some Value</asp:ListItem>
        </asp:DropDownList>
        <br />
        <asp:Button ID="Button1" Text="Check" runat="server" />
        <br />
        <br />
        <asp:RequiredFieldValidator ID="MyRequiredFieldValidator" ControlToValidate="DropDownList1"
             ErrorMessage="Please select a value from doropdown to proceed." runat="server" />
    </form>
</body>
</html>

No comments:

Post a Comment

Sponsored Ad

Development Updates