<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Using ValidationSummary</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Book
<br />
<asp:DropDownList ID="lstBooks" runat="server">
<asp:ListItem Value="0" Selected="True">Please pick a book</asp:ListItem>
<asp:ListItem Value="1">A</asp:ListItem>
<asp:ListItem Value="2">B</asp:ListItem>
<asp:ListItem Value="3">C</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="reqBook"
runat="server"
ControlToValidate="lstBooks"
SetFocusOnError="true"
Text="*"
InitialValue="0"
Display="static"
ErrorMessage="Please choose a book from list"/>
User Name:<br />
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqUserName"
runat="server"
ControlToValidate="txtUserName"
SetFocusOnError="true"
Text="*"
Display="static"
ErrorMessage="Please enter a User Name"/>
Password:<br />
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqPassword"
runat="server"
ControlToValidate="txtPassword"
SetFocusOnError="true"
Text="*"
Display="static"
ErrorMessage="Please enter a password"/>
<asp:ValidationSummary id="valSum"
runat="server"
DisplayMode="BulletList"
HeaderText="The following errors were found:"
ShowMessageBox="false"
ShowSummary="true" />
<asp:Button ID="btnSubmit" Text="Click this to test validation" runat="server" />
</div>
</form>
</body>
</html>
|