在内容页面上找到标签
我试图从用户控件(ascx)中找到内容页面上的标签,
Page p = this.Page;
//this line causes application to unload with no exception
ContentPlaceHolder cp = (ContentPlaceHolder)p.Master.FindControl("Content2");
Label label = (Label)cp.FindControl("SomeLabel");
它只是自行卸载,没有异常消息。为什么会发生这种情况?
I am trying to locate a label on a content page from within User Control(ascx)
Page p = this.Page;
//this line causes application to unload with no exception
ContentPlaceHolder cp = (ContentPlaceHolder)p.Master.FindControl("Content2");
Label label = (Label)cp.FindControl("SomeLabel");
It just unloads itself with no exception mesage. Why does it happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够让它工作,以便它从我的用户控件所在的
ContentPlaceHolder
中找到一个Label
:Site1.Master:
<强>默认.aspx:
WebUserControl1.ascx.cs:
I was able to get this to work so that it finds a
Label
from within aContentPlaceHolder
where my user control resides:Site1.Master:
Default.aspx:
WebUserControl1.ascx.cs: