我找不到从母版页继承的页面的页面加载事件控件。这是我的代码-
Image img =FindControl("ourPimg0") as Image;
任何建议都将不胜感激。
如果您试图在母版页中找到控件,您应该this.Master.FindControl("controlName")。
另一种情况是您在母版页内,并且希望在页内找到控件,因此您应该ContentPlaceHolder1.FindControl("controlName")。
还请检查:
- 如何在asp.net中从母版页访问内容页控件
- 嵌套母版页和.FindControl
在检查子页面中的控件时使用以下代码
ContentPlaceHolder1.FindControl("controlName")。它列出了该特定字段的控件。