通过以下简单的标记,我在FF和IE8中得到了非常奇怪的行为。如果我将焦点放在文本框中,然后按tab键离开,则什么也不会发生。如果我给出一个用户名的值,并立即删除它,什么也不会发生。然而,只有当我提供一个用户名,按tab键离开,删除它并再次按tab键离开时,我才最终得到一个红星"required“标记。摘要根本不显示。
这是我尝试使用的标记。看起来我的问题出在EnableClientScript和ValidationGroup上:
<asp:Label ID="userNameLabel" runat="server"
AssociatedControlID="userNameText">
User Name:
</asp:Label>
<asp:TextBox ID="userNameText" runat="server"
Width="200px">
</asp:TextBox>
<asp:RequiredFieldValidator ID="userNameRequired" runat="server"
ControlToValidate="userNameText"
Display="Dynamic"
EnableClientScript="true"
ValidationGroup="userValidation"
ErrorMessage="User Name is always required.">
*
</asp:RequiredFieldValidator>发布于 2010-05-05 08:57:07
您确定甚至需要EnableClientScript="true"吗?我想它默认是这样的。
https://stackoverflow.com/questions/2769737
复制相似问题