Solved

asp.net dynamic master page pulls in its aspx session

Posted on 2010-11-15
3
658 Views
Last Modified: 2012-06-27
can I have a an aspx page that chooses masterpage dynamically...then..that masterpage will lay out the page...then the session varaibles inside the aspx page will be inserted into...see code for sample...
<!--BEGIN MASTER PAGE MARKUP-->

<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site1.master.vb" Inherits="MasterPagesExample.Site1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <style type="text/css">
        html
        {
            background-color:white;
            font:14px Georgia,Serif;
        }
        .content
        {
            width:700px;
            margin:auto;
            border-style:2px solid black;
            background-color:white;
            padding:10px;
        }
        .header
        {
            width:700px;
            height:100px;
            border:1px solid grey;
        }
        .breadCrumb
        {
            width:700px;
            height:30px;
            border:1px solid red;
        }
        .menu
        {
            width:700px;
            height:30px;
            border:1px solid blue;
        }
        .centerSection
        {
            width:700px;
            height:302px;
        }
        .leftSide
        {
            width:148px;
            height:300px;
            border:1px solid green;
            float:left;
        }
        .mainContent
        {
            width:548px;
            height:300px;
            border:1px solid orange;
            float:right;
        }
        .upperFooter
        {
            width:700px;
            height:80px;
            border:1px solid brown;
        }
        .footer
        {
            width:700px;
            height:60px;
            border:1px solid grey;
        }
        </style>
    <title>Site Master</title>
</head>
<body>
<form id="form1" runat="server">    
<div class="content">
    <div class="header">
        <asp:contentplaceholder id="Header" runat="server">   
			<div>
 				<td>
				</td>
			</div>
 
        </asp:contentplaceholder>
    </div>
    <div class="menu">
        <asp:contentplaceholder id="Menu" runat="server">

<!-- HTML code HERE --->
        </asp:contentplaceholder>
    </div>
    <div class="breadCrumb"> 
        <asp:contentplaceholder id="Bread_Crumb" runat="server">   

<!-- HTML code HERE --->     
        </asp:contentplaceholder>
    </div>
    <div class="centerSection">
        <div class="leftSide">
            <asp:contentplaceholder id="Left_Side_Nav" runat="server"> 

<!-- HTML code HERE --->
            </asp:contentplaceholder>
        </div>
        <div class="mainContent">
            <asp:contentplaceholder id="Main_Content" runat="server"> 

<frameset cols="50%,50%">
    <frame src="frameA.html">
    <frame src="frameB.html">
</frameset>





            </asp:contentplaceholder>
        </div>
    </div>
    <div class="upperFooter">
        <asp:contentplaceholder id="Upper_Footer" runat="server">        
        </asp:contentplaceholder>
    </div>   
    <div class="footer">    
        <asp:contentplaceholder id="Footer" runat="server">              
        </asp:contentplaceholder>
    </div>        
</div>
</form>
</body>
</html>

<!--END MASTER PAGE MARKUP-->



<!--BEGIN WEBFORM1.ASPX MARKUP-->
<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="WebForm1.aspx.vb" Inherits="MasterPagesExample.WebForm1" 
    title="Untitled Page" %>


<script runat="server">

   Protected Overrides Sub OnPreInit(ByVal e As EventArgs)
      
        ' overide the curent masterpage
        Page.MasterPageFile = Session("SelectedTheme")


        MyBase.OnPreInit(e)
    End Sub


</script>


<asp:Content ID="Content1" ContentPlaceHolderID="Header" runat="server">
<p>Header content</p><br />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Bread_Crumb" runat="server">
<p>Bread_Crumb content</p>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Menu" runat="server">
<p>Menu content</p>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Left_Side_Nav" runat="server">

<%=Session("SessionThis_page_menu")%>

<p>Left_Side_Nav content</p>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Main_Content" runat="server">

<%=Session("SessionMain_content")%>
%=Session("SessionMain_content1")%>
%=Session("SessionMain_content2")%>

<p>Main content</p>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Upper_Footer" runat="server">
<p>Upper_Footer content</p>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Footer" runat="server">
<p>Footer content</p>
<center>Copyright &copy; 2010 by Dty</center>
</asp:Content>

<!--END WEBFORM1.ASPX MARKUP-->

Open in new window

0
Comment
Question by:GlobaLevel
3 Comments
 
LVL 10

Author Comment

by:GlobaLevel
ID: 34139027
?
0
 
LVL 21

Accepted Solution

by:
Alfred1 earned 500 total points
ID: 34142770
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 34148053
If you are looking to use different themes, I suggest you look in to theming asp.net applications, it's a simpler way to do what you are trying to accomplish.

http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question