【问题标题】:CompareValidator works in listview's editItemTemplate but not in insertitemtemplateCompareValidator 在 listview 的 editItemTemplate 中有效,但在 insertitemtemplate 中无效
【发布时间】:2009-07-09 16:55:32
【问题描述】:

我有一个验证问题

我有一个列表视图,在编辑项模板中我有两个复合控件,里面有一个文本框

我在上面放了一个比较验证器

<asp:CompareValidator ID="myCompareValidator" runat="server"
ControlToValidate="mycompositecontrol1" ControlToCompare="mycompositecontrol2"
Operator="GreaterThanEqual" Type="Date" Display="Dynamic" ErrorMessage="there is an error !"
Text="!"  ValidationGroup="myValidationGroup" />

效果很好!

所以我在 InserItemTemplate 中执行完全相同的操作(这是复制/粘贴)

但这一次,它不起作用,我的验证摘要中没有错误消息,并且在我的控件附近进行验证!

如果你知道这个问题,请帮助我

提前致谢

【问题讨论】:

    标签: asp.net custom-server-controls


    【解决方案1】:

    这并不是直接回答问题的好答案,但是:

    我从来没有在 ASP 验证器中获得过任何好运。我总是试着把他们的方钉钉在一个圆孔里一段时间,靠近一点,感到沮丧,然后用我自己的逻辑、标签中的错误消息以及用 CSS 样式切换可见性。

    附:当您复制粘贴您的验证器时,请确保您更改了它正在验证的控件...

    【讨论】:

    • 感谢您的回答,但我无法使用自己的逻辑,我必须使用 asp.net 验证器。我在我的应用程序的任何地方都使用 asp 验证器,没有问题。我遇到的唯一一个是 listview 的 insertitemtemplate 和我的复合控件 ControlToValidate 属性设置得很好,这不是问题
    猜你喜欢
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 2015-07-21
    • 2015-08-03
    • 2015-11-13
    相关资源
    最近更新 更多