我的验证器在哪里?

发布于 2024-09-05 10:16:25 字数 484 浏览 1 评论 0原文

我的页面中有一个验证器:

<asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="IdentifySEDSED1TxtDate" ErrorMessage="Significant Event Date 1 is missing" ValidType="SEDate">*</asp:RequiredFieldValidator>

我发现在 Page_Load 中:(下面是监视窗口的屏幕截图)

this.FindControl("rfv1")    {Text = "*"}    

rfv1    The name 'rfv1' does not exist in the current context

看,我可以使用 FindControl 获取此控件,但无法直接使用 ID 获取它!会发生什么?

I have a validator in my page:

<asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="IdentifySEDSED1TxtDate" ErrorMessage="Significant Event Date 1 is missing" ValidType="SEDate">*</asp:RequiredFieldValidator>

I found that in Page_Load: (below is a screen shot from the Watch Window)

this.FindControl("rfv1")    {Text = "*"}    

rfv1    The name 'rfv1' does not exist in the current context

See, I can get this control with FindControl, but I can't get it using ID directly! What happens?

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

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

发布评论

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

评论(1

阳光下的泡沫是彩色的 2024-09-12 10:16:25

如果您要在页面上查找面板,则需要在页面的表单中查找它们,因为面板放置在表单内,而不是直接放置在页面上。

至少我认为这就是问题所在......

这是否有效:

this.Form.FindControl(rfv1);

If you are finding the panels on the page, you need to find them in the form of the page, as panels are placed inside the form, but not on the page directly.

Atleast I assume that this is the problem....

does this work:

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