CustomValidator 不需要设置其 ControlToValidate 属性,因此

发布于 2024-09-04 08:58:49 字数 361 浏览 1 评论 0原文

我刚刚读完 CustomValidator 控件,我有一个问题。在我正在阅读的书中,它说 CustomValidator 不需要设置其 ControlToValidate 属性,并给出了一些该用法的示例。但在一个未使用 ControlToValidate 的示例中,OnServerValidate 函数有一个计时器(5 秒),您需要通过在文本框中输入“答案”来击败该计时器。如果您花费的时间超过 5 秒,则 CustomValidator 的错误消息会在文本框旁边弹出(这就像一个定时问答游戏)。 CustomValidator 如何知道将消息放置在文本框旁边(据我所知,两者之间没有关联)?我想对此进行测试,因此我在页面上添加了几个文本框,并且错误消息始终显示在我放置在页面上的最后一个文本框旁边。谢谢。

I've just finished reading up on the CustomValidator control and I have a question. In the book I'm reading, it says that a CustomValidator doesn't need to have it's ControlToValidate property set and it gives a few examples of that usage. But in one example where ControlToValidate isn't used, the OnServerValidate function has a timer (5 seconds) that you need to beat by entering your 'answer' into a textbox. If it takes you longer than 5 seconds, the CustomValidator's error message pops up next to the textbox (it's like a timed question/answer game) . How did the CustomValidator know to place the message next to the textbox (there's no association between the two, that I know of)? I wanted to test this, so I put a couple more textboxes on the page and the error message always showed up next to the last textbox I placed on the page. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼角的笑意。 2024-09-11 08:58:49

错误消息显示在 CustomValidator 控件的位置,它与 TextBox 的位置无关。另外,如果页面上有 ValidationSummary 控件,它也会显示在那里。

The error message shows up at the location of the CustomValidator control, it has nothing to do with the location of the TextBox. Also, if you have a ValidationSummary control on the page, it shows up there as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文