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. Two questions: Master pages and navigation

Two questions: Master pages and navigation

Scheduled Pinned Locked Moved ASP.NET
questioncsharpdotnettutorial
6 Posts 2 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.
  • D Offline
    D Offline
    davidstern100
    wrote on last edited by
    #1

    1. How do I switch between 2 master pages for the same content page? For example: one master page for a logged in user and a different one for a visitor. 2. In a function in a code-behind page in c#, how do I navigate back one page, like in the "Back" button of the browser?

    David Stern Online!

    M 1 Reply Last reply
    0
    • D davidstern100

      1. How do I switch between 2 master pages for the same content page? For example: one master page for a logged in user and a different one for a visitor. 2. In a function in a code-behind page in c#, how do I navigate back one page, like in the "Back" button of the browser?

      David Stern Online!

      M Offline
      M Offline
      Michael O
      wrote on last edited by
      #2

      Ad.1 You can set the MasterPage file in PreInit event. 2. What exactly would you like to do?

      D 1 Reply Last reply
      0
      • M Michael O

        Ad.1 You can set the MasterPage file in PreInit event. 2. What exactly would you like to do?

        D Offline
        D Offline
        davidstern100
        wrote on last edited by
        #3

        1. Using Visual Web Developer 2005 Express Edition, how do I link a function to the PreInit event? 2. I want to create a button that does a few things, and then redirects the user to the page he was previous to the current page (could be any page).

        David Stern Online!

        M 1 Reply Last reply
        0
        • D davidstern100

          1. Using Visual Web Developer 2005 Express Edition, how do I link a function to the PreInit event? 2. I want to create a button that does a few things, and then redirects the user to the page he was previous to the current page (could be any page).

          David Stern Online!

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

          1. public partial class Default : System.Web.UI.Page { protected void Page_PreInit() { if(IsPostBack) { this.MasterPageFile = "MasterPage2.master"; } } protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { //Call some event to cause page reload } } I'm not sure that is what you are looking, but remember the ID ContentPlaceHolder in Master1 and Master2 must be the same. 2. You can send a adres of previous page in hidden field or in viewstate or remember in session or in cache. Sorry for my english :)

          D 1 Reply Last reply
          0
          • M Michael O

            1. public partial class Default : System.Web.UI.Page { protected void Page_PreInit() { if(IsPostBack) { this.MasterPageFile = "MasterPage2.master"; } } protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { //Call some event to cause page reload } } I'm not sure that is what you are looking, but remember the ID ContentPlaceHolder in Master1 and Master2 must be the same. 2. You can send a adres of previous page in hidden field or in viewstate or remember in session or in cache. Sorry for my english :)

            D Offline
            D Offline
            davidstern100
            wrote on last edited by
            #5

            Yes, that's what I was looking for. I just have a casting problem: I've put this line on top of the aspx page: <%@ MasterType VirtualPath="~/MainMasterPage.master"%> The problem is that it's good for one of the masterpages (MainMasterPage) and not for the other, and I can put only one line of this type in the page. Without the MasterType line, when I try to do the casting in the code behind page, for example: (UserMasterPage)this.MasterPageFile = "~/UserMasterPage.master"; Then the string on the right side of the equation should be cast to UserMasterPage. Any suggestions?

            David Stern Online!

            M 1 Reply Last reply
            0
            • D davidstern100

              Yes, that's what I was looking for. I just have a casting problem: I've put this line on top of the aspx page: <%@ MasterType VirtualPath="~/MainMasterPage.master"%> The problem is that it's good for one of the masterpages (MainMasterPage) and not for the other, and I can put only one line of this type in the page. Without the MasterType line, when I try to do the casting in the code behind page, for example: (UserMasterPage)this.MasterPageFile = "~/UserMasterPage.master"; Then the string on the right side of the equation should be cast to UserMasterPage. Any suggestions?

              David Stern Online!

              M Offline
              M Offline
              Michael O
              wrote on last edited by
              #6

              Hmmm Please, describe me briefly what are you trying to do? Because it seems be a bit complicated or maybe you are trying to do very simple thing in very complicated way:)

              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