With the following simple mark-up, I get very strange behaviour in FF and IE8. If I give the textbox focus, and tab out, nothing happens. If I give a user name value, and erase it immediately开发者_开发知识库, nothing happens. However, only when I supply a user name, tab away, the erase it and tab away again, do I finally get a red star "required" mark. The summary doesn't show at all.
This is the markup I was trying with. Looks like my issue was with EnableClientScript and 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>
Are you sure EnableClientScript="true"
is even needed? I think it defaults to that.
精彩评论