简明ASP.NET验证摘要 [英] Concise ASP.NET Validation Summary
本文介绍了简明ASP.NET验证摘要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有什么办法让ASP.NET验证摘要控制,只是显示的HeaderText时,有一个验证错误?
is there any way to get the ASP.NET validation summary control to just display the HeaderText when there is a validation error?
基本上我想要的是只是一个简单的消息,如请填写标有各个领域的*旁边的提交按钮出现。当我使用*关于验证错误消息我不希望这些出现在汇总。
Basically what I want is for just a simple message like "Please complete all fields marked *" to appear next to the submit button. As I'm using "*" for the error message on the validators I don't want these to appear in the summary.
感谢您的帮助。
推荐答案
设置每个验证文本以*和的ErrorMessage ,以一个空字符串。
Set each validators Text to "*" and ErrorMessage to an empty string.
<form id="form2" runat="server">
Name:<br />
<asp:TextBox ID="NameTextBox" runat="server" />
<asp:RequiredFieldValidator
ID="NameTextBoxRequiredValidator"
ControlToValidate="NameTextBox"
ErrorMessage=""
Text="*"
runat="server" />
<br />
City:<br />
<asp:TextBox ID="CityTextBox" runat="server" />
<asp:RequiredFieldValidator
ID="CityTextBoxRequiredValidator"
ControlToValidate="CityTextBox"
ErrorMessage=""
Text="*"
runat="server" />
<br />
<asp:Button ID="SubmitButton" Text="Submit" runat="server" />
<hr />
<asp:ValidationSummary
ID="valSum"
DisplayMode="SingleParagraph"
HeaderText="Please complete all fields marked *"
runat="server" />
</form>
这篇关于简明ASP.NET验证摘要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文