Saturday, January 30, 2010

Accessing Master Page Properties from Child Page

 Hello Friends.

Today hot topic is that how to access properties from MasterPage into content page.
I think there is several methods you can access those properties or variable.

1. By Master property of content page
2. By interface
3. By Including a MasterPage Directive in Pages.

So here i am providing you some code stuff for the same.
1. Access Master Page properties and Method by Master property of Page.

Master Page Code

     public string ButtonText
           get { return this.Button1.Text; }
           set { this.Button1.Text = value; }

Child Page Code

        //Master page is the name of master page file
        MasterPage mast = this.Master as MasterPage;
        if (mast != null)
            mast.ButtonText = "New Text";

2. Access Master Page properties and Via Interface.
see here

No comments:

Post a Comment