Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Can I remove Master Page in the program?

Can I remove Master Page in the program?

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    J Liang
    wrote on last edited by
    #1

    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

    Steve EcholsS N M 3 Replies Last reply
    0
    • J 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

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      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.PreInit

      Me.MasterPageFile = "~/yes\_my.master"
      

      End Sub


      - S 50 cups of coffee and you know it's on!

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      1 Reply Last reply
      0
      • J 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

        N Offline
        N Offline
        nandhububbly
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • J 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

          M Offline
          M Offline
          Michael Sync
          wrote on last edited by
          #4

          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, 2007

          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. :)

          G 1 Reply Last reply
          0
          • N nandhububbly

            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

            M Offline
            M Offline
            Michael Sync
            wrote on last edited by
            #5

            :) 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. :)

            1 Reply Last reply
            0
            • M Michael Sync

              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, 2007

              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. :)

              G Offline
              G Offline
              ganeshvittal
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups