验证摘要未正确呈现
有没有人见过这个并且有人知道如何修复它...
验证摘要控件似乎正在呈现此内容:
error message
<br>
error message
<div style="display: none;" id="summaryID">
</div>
如果我在这里错了,请纠正我,但我的错误不应该在该 div 内...因此是原因您可以使用 CssClass="whatever" 在控制服务器端放置一个 cssclass 吗?
或者我错过了什么?
编辑:
只是为了验证......这就是我期望它呈现的内容:
<div style="display: none;" id="summaryID">
error message
<br>
error message
</div>
编辑2:
产生这个的服务器端标记是
<asp:ValidationSummary ID="ui_ValidationSummary" runat="server" />
...... 大量的控件,但这里有一个例子(不想让事情变得过于复杂): ...
<asp:TextBox ID="ui_txtClientDOB" runat="server" />
<asp:RangeValidator ID="ui_RangeValidator_DOB" runat="server" ControlToValidate="ui_txtClientDOB" ErrorMessage="DOB is not valid" MinimumValue="1900/01/01" Type="Date" ForeColor="Red">*</asp:RangeValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ui_txtClientDOB" ErrorMessage="DOB is missing" ForeColor="Red">*</asp:RequiredFieldValidator>
如果此文本框中的任一验证器有理由验证失败,结果如所讨论的那样,一个空的 div 标签,旁边有一个错误。
Has anyone ever seen this and does anyone know how to fix it ...
The validation Summary control seems to be rendering this :
error message
<br>
error message
<div style="display: none;" id="summaryID">
</div>
Correct me if i'm wrong here but shouldn't my errors be inside that div ... hense the reason you can put a cssclass on the control server side using CssClass="whatever" ?
Or did i miss something?
EDIT :
Just to verify ... this is what i expect it to render :
<div style="display: none;" id="summaryID">
error message
<br>
error message
</div>
EDIT 2 :
Server side markup that produces this is ...
<asp:ValidationSummary ID="ui_ValidationSummary" runat="server" />
...
Loads of controls but here's an example (don'twant to over complicate things) :
...
<asp:TextBox ID="ui_txtClientDOB" runat="server" />
<asp:RangeValidator ID="ui_RangeValidator_DOB" runat="server" ControlToValidate="ui_txtClientDOB" ErrorMessage="DOB is not valid" MinimumValue="1900/01/01" Type="Date" ForeColor="Red">*</asp:RangeValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ui_txtClientDOB" ErrorMessage="DOB is missing" ForeColor="Red">*</asp:RequiredFieldValidator>
If either validator on this textbox has reason to fail the validation the result is as discussed, an empty div tag with an error next to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
div #summaryID 可能是显示客户端验证错误的地方。使用像 firebug 这样的工具来查看这一点,因为您无法在 javascript 填充标记上查看源代码。否则,关闭客户端验证并进行回发。
编辑
我的猜测是您将显示的错误消息与验证控件本身而不是验证摘要内的错误消息混淆了。如果您不向验证控件提供文本属性,它将使用错误消息。尝试以下操作(去掉文本属性,您就会明白我的意思):
Likely the div #summaryID is where client side validation errors are show. Use a tool like firebug to see this as you can't do a view source on javascript filled markup. Otherwise, turn off client side validation and do a postback.
Edit
My guess is that you are mixing up the error message that's displayed with the validation control itself instead of inside the validation summary. If you don't supply a text property to the validation controls it will use the error message. Try the following (take away the text property and you'll see what I mean):