DropDownList Control Validation in Using Asp.Net C#

DropDownList Validation


DropDownList Control Validation Using RequirdField Validation Before Inserting or Assigning Values  Using in Asp.Net C#.

                          Download Coding

                                                Download

                                    
                                    DEMO



HTML CODING


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>Select City</asp:ListItem>
            <asp:ListItem>New Delhi</asp:ListItem>
            <asp:ListItem>London</asp:ListItem>
            <asp:ListItem>Paris</asp:ListItem>
            <asp:ListItem>Perth</asp:ListItem>
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" ErrorMessage="Please  Select City" ForeColor="#CC3300" InitialValue="Select City"></asp:RequiredFieldValidator>
       
        <asp:Button ID="Button1" runat="server" Text="Submit" />
   
    </div>
    </form>
</body>
</html>


First - Add New Form - Select DropDownList - Edit Item - Add ListItems - Change Text name - Ok





Next - Add - Required Fields Validation - Chage Property - Initial Value,Control to Validate,Error Message






Next - Run[F5] - Without Select City - Show Error Message








0 comments:

Post a Comment