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

Set Property Value on Master Page from Content Page

ASP.Net ASP.Net 
1 Comment(s)
 5903  View(s)
Rate this:

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




      return _master;




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


By Sushant Mishra on   2 months ago

It is great to associate with such a blog.

Don't want to miss updates? Please click the below button!

Follow MindStick