我的验证器 ErrorMessage 中需要一些动态文本。
这是我正在尝试做的,但它不起作用:
<td>
<asp:TextBox runat="server" ID="tbIncome_A_3" MaxLength="12"></asp:TextBox>
<asp:CompareValidator ID="comvIncome_A_3" runat="server" ControlToValidate="tbIncome_A_3" Display="Dynamic" Operator="DataTypeCheck" Type="Currency"
ErrorMessage="*Value entered for <%=DateTime.Today.Year - 3 %> Income must be a dollar value.">
<span class="alert">*</span>
</asp:CompareValidator>
</td>
...
<div>
<asp:ValidationSummary ID="vs" runat="server" CssClass="alert alert-danger alert-dismissible" HeaderText="This page has been saved, but it's not complete." ForeColor="" EnableClientScript="false" EnableViewState="false" />
</div>
我希望<%=DateTime.Today.Year - 3 %>
在 ValidationSummary 中呈现为“2014”,但它却呈现为纯文本。我觉得我错过了一些非常微不足道的东西来完成这项工作。