Thursday 18 October 2012

Calling MasterPage Method from Content Page CodeBehind

 

Calling MasterPage Method from Content Page CodeBehind

 

Today I will explain how to call the method in your masterpage from the Content Page Code Behind..


public partial class MasterPage : System.Web.UI.MasterPage

{

   public void ShowLabelDetails()

   {

      this.lblDetails.Visible = true;

   }

   public void HideLabelDetails()

   {

      this.lblDetails.Visible = false;

   }

}


Now in the Content Page Codebehind:


MasterPage master = (MasterPage)this.Master;

master.ShowLabelDetails(); 


Here MasterPage is the class name of class in Master.

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top