Master page in ASP.net

Asked By Abhi Rana
07-Nov-09 12:50 AM
Earn up to 0 extra points for answering this tough question.

How could we enable and disable Master page on runtime.

I have aspx page that has master page, I want to set it visible false at run time.

  Disable Master Page

F Cali replied to Abhi Rana
07-Nov-09 01:00 AM

Taking it from the following link:

http://www.eggheadcafe.com/community/aspnet/7/10021745/disable-master-page.aspx

"Create a second master page that is effectively blank. Then use the PreInit method of the page to check for your target situation and load the blank master page instead."

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles Me.PreInit

If SpecialSituation = True Then
Me.MasterPageFile = "CustomAppBlank.master" End If End Sub

  Re:

web mavin replied to Abhi Rana
07-Nov-09 01:07 AM
The first option that comes to my mind is setting visibility of all controls inside master page at runtime. That should be easy. Or you could have another empty master page and set that when you want to hide the current one.

  Also..

web mavin replied to Abhi Rana
07-Nov-09 01:09 AM
you could expose the Table from the master page. You can do that by addind a property to your master page. From the Content page you can use the Master class to access your property:

MasterPage:
public Table GetTable
{
    get { return myTable1; }
}
Conentpage:

Master.GetTable.Visible = false;

Check out this post for more details of how you use the Master class to access a member located in a master page file.
Create New Account