How to access Master page controls from the Content page
2006-07-19 23:39
781 查看
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";
}
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";
}
相关文章推荐
- How to access HBase from spark-shell using YARN as the master on CDH 5.3 and Spark 1.2
- How to remove a block from the particular page?
- The way to access control in sub-page witin masterpage
- How To Retrieve the URL of a Web Page from an ActiveX Control
- [Drupal] How to change the content from English to language Language neutral
- How to hide & unhide the grid from the page by using people code?
- How to pass a value from User Control to the Page
- How-to: Set up the delta upload for Vendor Master Data from CRM to ERP
- Interacting with the Master Page from the Content Page
- How to see the Master Page option Under Look and Feel in site settings?
- How to set the DefaultButton in a Page Based on ASP.NET Master Page
- How to Add ASP.NET User Controls To Master Pages or Page Layouts
- Master Pages / Content Pages. How to set the Form ID?
- Master Pages / Content Pages. How to set the Form ID?
- How to access UI controls from a user defined class (CFormView based SDI application)
- How to obtain access to an ActiveX control from its property page 如何从一个控件的属性页中获取对该控件的访问?
- How to access Dropbox from the command line in Linux
- How to use the Install from Media feature to promote Windows Server 2003-based domain controllers
- [Salesforce] How to determine the login environment from Apex
- How to sovle the VSS error -- Error reading from file