您的位置:首页 > 其它

How to access Master page controls from the Content page

2006-07-19 23:39 731 查看
How to access Master page controls from the Content page[/b]

At first, use the Page.Master property to get a reference to the actual master page instance, the use the Master.FindControls method to find and reference the controls declared in the Master page.

For example,

MasterPage master = Page.Master;

UserControl headerControl = (UserControl)(master.FindControl("PageHeader1"));

HtmlImage imgHead = (HtmlImage)(headerControl.FindControl("img0Category"));

if(imgHead != null)

{

imgHead.Src = "/images/categoryb.gif";

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: