In this blog I am going to explain how to set value of property on the master page, so that property can be easily access on its content page.

If you need to pass data to a variable from content page to master page

you have to create a property in master page.

Create a property in your master page:

protected static string _master = "home";

public string Section
{    get
   {
      return _master;
   }
   set
   {
       _master = value;
   }
}

After creating a property in a master page you have to add a directive in

the child or content page.

Add page directive to your content page:
<%@ MasterType VirtualPath="~/MasterPage.master" %>

After creating   a property in the master page and adding a directive in the

content page, now you can easily access the property in all the child pages

which inherit master page directive.

You can access this property like this:
Master.Section = "hello";
  Modified On Sep-18-2014 01:24:00 PM

Leave Comment