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 
{ 
set 
 { 
 lbtnMailBox .Visible = value; 
 }
} 

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

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