Validating a DropDownList in C# Asp.Net

Validating a DropDownList in C# Asp.Net

Use RequiredFieldValidator and set the initial value to the default starting item in the list.         
<td>
        <asp:DropDownList ID=”ctype” runat=”server”>
        <asp:ListItem>Select Credit Card Type</asp:ListItem>
            <asp:ListItem>Visa</asp:ListItem>
            <asp:ListItem>Amex</asp:ListItem>
            <asp:ListItem>MasterCard</asp:ListItem>
            <asp:ListItem>Discover</asp:ListItem>
        </asp:DropDownList>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ErrorMessage=”Please Select Card Type” ControlToValidate=”ctype” InitialValue=”Select Credit Card Type”>
</asp:RequiredFieldValidator>
</td> 

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.