ValidatorCallout控件,該控件用於用戶控件中輸入不符合格式要求的內容之後,提示操作錯誤信息。
<%...@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidatorCalloutDemo.ASPx.cs"
Inherits="ValidatorCalloutDemo" %>
<%...@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="ASP" %>
<%...@ Register Assembly="AjaxControlToolkit" Namespace="AJaxControlToolkit" TagPrefix="cc1" %>
<!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>無標題頁</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" Border
BorderWidth="1px" BorderColor="#a9a9a9" /></td>
</tr>
</table>
<br />
<ASP:RegularExpressionValidator runat="server" ID="PNRegEx"
ControlToValidate="MailTextBox" Display="None" ErrorMessage="<b>格式不正確</b><br />請按如下格式填寫<br />[email protected]" 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>