ValidatorCallout是一个用来绑定验证控件的提醒控件,替换“错误信息”为“弹出模式对话框”。其主要是作为ASP.NET2.0中验证控件的扩展。
属性列表:
targetcontrolid:要实现提示功能的验证控件ID
弹出提示信息的宽度
highlinghtcssclass:弹出信息应用的样式
warningiconimageurl:弹出信息中的警告图片地址
closeimageurl:弹出信息中使用的关闭图片地址
实例解析一、默认功能实现(使用默认的样式和关闭按钮图片)
<form id="form1" runat="server">
<div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager></div>
<table style=" 549px; height: 91px">
<tr>
<td style=" 5px">name:</td>
<td style=" 100px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
Display="None" ErrorMessage="name不能为空"></asp:RequiredFieldValidator>
<cc1:validatorcalloutextender id="ValidatorCalloutExtender1" runat="server" targetcontrolid="RequiredFieldValidator1"></cc1:validatorcalloutextender>
</td>
</tr>
<tr>
<td style=" 5px">password:</td>
<td style=" 100px"><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
Display="None" ErrorMessage="pwd不能为空"></asp:RequiredFieldValidator>
<cc1:validatorcalloutextender id="ValidatorCalloutExtender2" runat="server" targetcontrolid="RequiredFieldValidator2"></cc1:validatorcalloutextender>
</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>