blog

Home / DeveloperSection / Blogs / Set Property Value on Master Page from Content Page

Set Property Value on Master Page from Content Page

Chris Anderson8344 17-Oct-2011

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

Updated 18-Sep-2014
hi I am software developer at mindstick software pvt. ltd.

Leave Comment

Comments

Liked By