Click here to Skip to main content
16,018,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello...
How we access master page controls and methods in child page
Posted
Comments
F-ES Sitecore 14-Oct-15 4:59am    
Put your question into google and you'll find plenty of examples. Please do your own basic research before asking questions. You might also want to pay attention to the order that events fire in master\content pages

https://msdn.microsoft.com/en-us/library/dct97kc3.aspx

1 solution

C#
Label myLabel = (Label)Master.FindControl("myLabelFromMasterPage"); // access the control from master page

// mater page
public MyMasterPage: MasterPage
{
    public int Add(int a, int b) 
    {
        return a + b;
    }
}
// content page
(this.Master as MyMasterPage).Add(5, 5);


-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900