Can I remove Master Page in the program?
-
Hi, I was wondering whether is it possible for me to remove the Master Page that was previously attached to one page in the program. For example, when some criterias are met, I want the Master Page to off from the page so that I don not need to create another same aspx page without the Master Page. Thanks in advance. J Liang
-
Hi, I was wondering whether is it possible for me to remove the Master Page that was previously attached to one page in the program. For example, when some criterias are met, I want the Master Page to off from the page so that I don not need to create another same aspx page without the Master Page. Thanks in advance. J Liang
You can, but I think it needs to be in PreInit or before: C#:
protected override void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "~/yes_my.master";
}VB:
Protected Sub Page_PreInit(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles Me.PreInitMe.MasterPageFile = "~/yes\_my.master"
End Sub
- S 50 cups of coffee and you know it's on!
-
Hi, I was wondering whether is it possible for me to remove the Master Page that was previously attached to one page in the program. For example, when some criterias are met, I want the Master Page to off from the page so that I don not need to create another same aspx page without the Master Page. Thanks in advance. J Liang
Hi u can remove ur master page ok no problem .. what u do means , 1.remove ur masterpage reference from ur <@ page > page directive 2. add ur user control what u mentioned in master page that user control 3.add ur HTML guide reference 4.add ur html tags like hetml,head,title,and if u r using any any some script funtion.. thats all.. incase u cant do it send ur .aspx page and ur masterpage to my id. n.nanthakumar@gmail.com Reg nantha
-
Hi, I was wondering whether is it possible for me to remove the Master Page that was previously attached to one page in the program. For example, when some criterias are met, I want the Master Page to off from the page so that I don not need to create another same aspx page without the Master Page. Thanks in advance. J Liang
I don't think you can remove the master page but you can change the master page. So, you can two master pages in your website. Change it at
Page_PreInit
event. Eg:protected void Page_PreInit(object sender, EventArgs e) { this.MasterPageFile = "MasterPage2.master"; }
Edit: I didn't see Steve's reply. I think his reply is the answer.. I forget to click "Submit" button before going lunch. -- modified at 2:07 Thursday 16th August, 2007Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
Hi u can remove ur master page ok no problem .. what u do means , 1.remove ur masterpage reference from ur <@ page > page directive 2. add ur user control what u mentioned in master page that user control 3.add ur HTML guide reference 4.add ur html tags like hetml,head,title,and if u r using any any some script funtion.. thats all.. incase u cant do it send ur .aspx page and ur masterpage to my id. n.nanthakumar@gmail.com Reg nantha
:) I think he wants to remove dynamically from Code.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
I don't think you can remove the master page but you can change the master page. So, you can two master pages in your website. Change it at
Page_PreInit
event. Eg:protected void Page_PreInit(object sender, EventArgs e) { this.MasterPageFile = "MasterPage2.master"; }
Edit: I didn't see Steve's reply. I think his reply is the answer.. I forget to click "Submit" button before going lunch. -- modified at 2:07 Thursday 16th August, 2007Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
Before designing a web application using Master pages try to have two master page files: 1) Master page with Header. 2) Master page without Header. Whenever you dont require the header part do the following code protected void Page_PreInit(object sender, EventArgs e) { this.MasterPageFile = "MasterWOHeader.master"; } The Idea behind this is, normally we use to include the common javascript functions in the master page since its a generic container. If you remove the masterpage then it might give you some problem[Since masterpage holds the generic javascript code], its better to embed the common javascript files in both the masterpages and use it in the required scenario. Thanks, Ganesh Kumar