Content page to Master page communication

One way of Content page to Master page communication is having properties or methods in master page and call them form content page.
Simply add @ Master Type directive in content (.aspx) page and mention virtual path to your master page

<%@ MasterType VirtualPath="~/MailBox/ThenMail.master"%> 

Above line will create a strongly typed reference to master page and by using Master property we can access methods and properties of master page in content page.

Here I am declaring a property in my master page’s cs class:

public bool MailBoxVisibility 
 lbtnMailBox .Visible = value; 

Now see how easily we can access this property in  content page .cs class.

Master.MailBoxVisibility = false; lbtnMailBox .Visible = value; 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s