我的验证器在哪里?
我的页面中有一个验证器:
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您要在页面上查找面板,则需要在页面的表单中查找它们,因为面板放置在表单内,而不是直接放置在页面上。
至少我认为这就是问题所在......
这是否有效:
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: