ASP.NET ValidationSummary

时间:2015-11-18 13:00:17

标签: asp.net validation requiredfieldvalidator validationsummary

我有一个包含不同必填字段的表单。

我还有ValidationSummary,如果未填写某些必填字段,则会在点击提交按钮时显示弹出窗口。

<asp:ValidationSummary runat="server" ID="vsValidationSummary" ValidationGroup="DefaultGroup" DisplayMode="BulletList" ForeColor="Red" ShowMessageBox="true" ShowSummary="false" />

当填写除一个以外的所有字段(参见下面的字段)时,会显示弹出窗口(确定),但只显示消息:

- Required

对于其他字段,&#34;必需&#34;

旁边有名称

失败的字段如下:

<div class="formFieldLine">
     <span class="userFormLabel">
          <ab:FormLabel Colon="false" runat="server" AssociatedControlID="ddlSuperstructureType" Text="<%$ Resources:lbSuperstructureType.Text %>" />
     </span>
     <ab:LabelledDropDownlist ID="ddlSuperstructureType" runat="server" DataSourceID="dsSuperstructureTypes" DataTextField="Text" DataValueField="Value" CssClass="dropdownSTypeBuyBack" />
     <asp:CustomValidator ID="cvSuperstructureType" runat="server" ControlToValidate="ddlSuperstructureType" ClientValidationFunction="ddlSelected_Validate" ValidationGroup="DefaultGroup"
                    CssClass="validatorMessage" ErrorMessage="<%$ Resources:Messages,RequiredField %>" OnServerValidate="ddlSelected_Validate"/>
     <br />
</div>

这是一个工作领域

<div class="formFieldLine">
     <span class="userFormLabel">
          <ab:FormLabel Colon="false" runat="server" AssociatedControlID="tbLeasingDuration" Text="<%$ Resources:lblLeasingDuration.Text %>" />
     </span>
     <ab:LabelledTextBox ID="tbLeasingDuration" runat="server" MaxLength="100" />
     <asp:RequiredFieldValidator ID="rvfLeasingDuration" ErrorMessage="<%$ Resources:Messages,RequiredField %>" ControlToValidate="tbLeasingDuration" runat="server" ValidationGroup="DefaultGroup" ForeColor="Red" />
     <br />
     <asp:RangeValidator ID="rvLeasingDuration" Type="Double" ErrorMessage="<%$ Resources:Messages,InvalidNumber %>" ControlToValidate="tbLeasingDuration" ValidationGroup="DefaultGroup" runat="server" MinimumValue="0" MaximumValue="999999999" ForeColor="Red" Display="Dynamic" style="margin-left : 212px;"/>
</div>

这是弹出窗口的打印屏幕: enter image description here

2 个答案:

答案 0 :(得分:0)

不要传递上述错误消息,而是传递您需要显示的消息......

答案 1 :(得分:0)

检查你的渲染块 - 这看起来不正确:

<%$ Resources:Messages,RequiredField %>

应该这样吗?

<%= Resources:Messages,RequiredField %>