ValidatorCallout控件,该控件用于用户控件中输入不符合格式要求的内容之后,提示操作错误信息。
<%
@PageLanguage
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
ValidatorCalloutDemo.aspx.cs
"
Inherits = " ValidatorCalloutDemo " %>
<% @RegisterAssembly = " System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,
PublicKeyToken=31bf3856ad364e35 "
Namespace = " System.Web.UI " TagPrefix = " asp " %>
<% @RegisterAssembly = " AjaxControlToolkit " Namespace = " AjaxControlToolkit " TagPrefix = " cc1 " %>
<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 无标题页 </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
< asp:ScriptManager ID ="ScriptManager1" runat ="server" >
</ asp:ScriptManager >
< table >
< tr >
< td > 电子邮件: </ td >
< td >< asp:TextBox runat ="server" ID ="MailTextBox" BorderStyle ="solid"
BorderWidth ="1px" BorderColor ="#a9a9a9" /></ td >
</ tr >
</ table >
< br />
< asp:RegularExpressionValidator runat ="server" ID ="PNRegEx"
ControlToValidate ="MailTextBox" Display ="None" ErrorMessage ="<b>格式不正确</b><br/>请按如下格式填写<br/>carol@sina.com" ValidationExpression ="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*" />
< asp:Button ID ="Button1" runat ="server" Text ="提交" />
< cc1:ValidatorCalloutExtender runat ="Server" ID ="PNReqE" TargetControlID ="PNRegEx"
Width ="100px" />
</ div >
</ form >
</ body >
</ html >
Inherits = " ValidatorCalloutDemo " %>
<% @RegisterAssembly = " System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,
PublicKeyToken=31bf3856ad364e35 "
Namespace = " System.Web.UI " TagPrefix = " asp " %>
<% @RegisterAssembly = " AjaxControlToolkit " Namespace = " AjaxControlToolkit " TagPrefix = " cc1 " %>
<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 无标题页 </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
< asp:ScriptManager ID ="ScriptManager1" runat ="server" >
</ asp:ScriptManager >
< table >
< tr >
< td > 电子邮件: </ td >
< td >< asp:TextBox runat ="server" ID ="MailTextBox" BorderStyle ="solid"
BorderWidth ="1px" BorderColor ="#a9a9a9" /></ td >
</ tr >
</ table >
< br />
< asp:RegularExpressionValidator runat ="server" ID ="PNRegEx"
ControlToValidate ="MailTextBox" Display ="None" ErrorMessage ="<b>格式不正确</b><br/>请按如下格式填写<br/>carol@sina.com" ValidationExpression ="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*" />
< asp:Button ID ="Button1" runat ="server" Text ="提交" />
< cc1:ValidatorCalloutExtender runat ="Server" ID ="PNReqE" TargetControlID ="PNRegEx"
Width ="100px" />
</ div >
</ form >
</ body >
</ html >