Validating Drop-Down Lists with the RequiredFieldValidator Control

<%@ Page Language="VB" %>

<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = "Page is valid!"
End Sub

<html xmlns="" >
<head id="Head1" runat="server">
<form id="form1" runat="server">
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem Selected="True">Select a profession</asp:ListItem>
<asp:RequiredFieldValidator id="RequiredFieldValidator1"
ErrorMessage="Please make a selection"
InitialValue="Select a profession">
<br />
<asp:Button ID="Button1" Runat="server" Text="Submit"
OnClick="Button1_Click" />
<br />
<br />
<asp:Label ID="Label1" Runat="server"></asp:Label>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s