How to access Master page controls from the Content page

 

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";

}

 

 

相关文章:

  • 2021-07-20
  • 2021-07-11
  • 2021-09-23
  • 2021-09-03
  • 2021-12-11
  • 2022-02-03
  • 2022-12-23
  • 2021-07-10
猜你喜欢
  • 2021-12-21
  • 2021-07-26
  • 2022-12-23
  • 2021-08-07
  • 2021-08-13
  • 2022-12-23
  • 2021-08-31
相关资源
相似解决方案