问题描述
我的内容页面上有一个lable,内容页面上也有一个lable.我想获得master页面上一个LABLE的值,我在内容页面里这样写的:protectedvoidPage_LoadComplete(objectsender,EventArgse){if(!IsPostBack){Label1.Text=(Master.FindControl("Label")asLabel).Text;}}结果报错:什么Objectreferencenotsettoaninstanceofanobject.//Page_LoadComplete这个事件难道每次还要自己手动添加一般只有Page_Load这个事谢谢。
解决方案
解决方案二:
<%@MasterTypeVirtualPath="~/Emedia/MasterPage.master"%>在页面源中加上以上代码试一试
解决方案三:
我已经把master页面放进来了现在就是想从内容页面去访问master页面服务器控件的值
时间: 2024-09-17 04:24:58