asp net RegularExpressionValidator在无效时不显示消息

时间:2016-11-21 11:55:44

标签: asp.net

我有一个非常简单的场景:

的.ascx:

<div class="record">
  <div id="label1" class="label">First name</div>
    <div class="value">
      <telerik:RadTextBox runat="server" ID="firstName" ClientIDMode="Static" Width="200"></telerik:RadTextBox>
    </div>
    <div class="validation">
      <asp:RegularExpressionValidator ID="firstNameRegularExpresionValidator1" ClientIDMode="Static" runat="server" ControlToValidate="firstName" SetFocusOnError="True" ValidationExpression="<%# NameValidatorProp.FirstName.Regex %>" ErrorMessage="<%# NameValidatorProp.FirstName.ErrorMessage %>" Display="Dynamic" />
    </div>
  </div>

在.ascx.cs文件中,我初始化了NameValidatorProp。

问题是发生了验证并且正则表达式验证器带有display:inline当word与regex不匹配时,但验证错误不是。当我将ErrorMessage从后面的代码更改为const字符串时的事件。如果我输入硬编码的ErrorMessage,它当然有效。

解决方法是在页面上将ErrorMessage属性设置为我拥有的值。它有效,但是当我有一些文本框项目时,它看起来很丑陋。

为什么ErrorMessage永远不显示值的任何建议?

1 个答案:

答案 0 :(得分:1)

使用这种声明性语法时,必须将 //filtering your log file grok { patterns_dir => ["/pathto/patterns"] <--- you could have a pattern file with such expression LOGTIMESTAMP %{YEAR}%{MONTHNUM}%{MONTHDAY} %{TIME} if you have to change the timestamp format. match => { "message" => "^%{LOGTIMESTAMP:logtimestamp}%{GREEDYDATA}" } } //overriding the existing timestamp with the new field logtimestamp mutate { add_field => { "timestamp" => "%{logtimestamp}" } remove_field => ["logtimestamp"] } //inserting the timestamp as UTC date { match => [ "timestamp" , "ISO8601" , "yyyyMMdd HH:mm:ss.SSS" ] target => "timestamp" locale => "en" timezone => "UTC" } 添加到DataBind()Read more

Page_Load