<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidatorsExample3.aspx.cs" Inherits="Validators.ValidatorsExample3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Validators Example</title>
<style type="text/css">
#form1
{
z-index: 1;
left: 10px;
top: 130px;
position: absolute;
height: 19px;
width: 754px;
}
</style>
</head>
<body bgcolor="#ffff99">
<h3>This example
demonstrates the use of Custom Validator controls and server-side
code to
validate a form's controls.</h3>
<ul>
<li>Employee Name Textbox uses a RequiredFieldValidator
control.</li>
<li>Hourly Rate Textbox uses a CustomValidator
control.</li>
<li>Security Level Textbox uses a CustomValidator
control.</li>
</ul>
<form id="form1" runat="server">
<asp:Label ID="lblMessage" runat="server" Font-Bold="True"
style="z-index: 1; left: 10px; top: 54px; position: absolute" />
<asp:TextBox ID="txtName" runat="server" Height="19px" Width="180px"
style="z-index: 1; left: 153px; top: 87px; position: absolute"></asp:TextBox>
<asp:RequiredFieldValidator ID="valName" runat="server"
ControlToValidate="txtName" ErrorMessage="* Required" Font-Bold="False"
ForeColor="#CC0000"
style="z-index: 1; left: 342px; top: 86px; position: absolute; height: 19px"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtRate" runat="server" Height="19px" Width="70px"
style="z-index: 1; left: 153px; top: 124px; position: absolute; bottom: 349px"></asp:TextBox>
<asp:CustomValidator ID="valRate" runat="server"
ControlToValidate="txtRate" ErrorMessage="* Enter a
numerical value under 100"
ForeColor="#CC0000"
style="z-index: 1; left: 235px; top: 125px; position: absolute" OnServerValidate="valRate_ServerValidate"></asp:CustomValidator>
<asp:TextBox ID="txtSecurityLevel" runat="server" Height="19px" Width="70px"
style="z-index: 1; left: 151px; top: 161px; position: absolute"></asp:TextBox>
<asp:CustomValidator ID="valSecurityLevel" runat="server"
ErrorMessage="* Invalid Level
(value must be 0 - 5)"
ControlToValidate="txtSecurityLevel" ForeColor="#CC0000"
style="z-index: 1; left: 234px; top: 162px; position: absolute" OnServerValidate="valSecurityLevel_ServerValidate"></asp:CustomValidator>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" Height="25px"
Width="75px"
style="z-index: 1; left: 148px; top: 210px; position: absolute" OnClick="btnSubmit_Click" />
<asp:Label ID="Label1" runat="server"
style="z-index: 1; left: 38px; top: 86px; position: absolute"
Text="Employee Name:"></asp:Label>
<asp:Label ID="Label2" runat="server"
style="z-index: 1; left: 62px; top: 123px; position: absolute"
Text="Hourly Rate: "></asp:Label>
<asp:Label ID="Label3" runat="server"
style="z-index: 1; left: 49px; top: 158px; position: absolute; right: 613px; height: 22px;"
Text="Security Level:"></asp:Label>
</form>
</body>
</html>