Accessing a property on a MasterPage from the content page. One merely has to check the namespace and the class name of the masterpage, which can be found in the code behind file. Just cast the Content Page’s Master as the class of the masterpage file which it uses, and then access the value.
One way of doing this in the content page,
int valueNeeded = ((MyNameSpace.MyMasterPageClassName)Master).MyProperty;
Or you can do this by doing like this in ContentPage.aspx page
<%@ MasterType VirtualPath="~/MasterPage.master" %>
Just below the Page directive and then you can access the proeprty in codebehind in content file as as:
int valueNeeded = Master.MyProperty;
Using these methods you can access a property of a masterpage file.
No comments:
Post a Comment