Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net dynamic master page pulls in its aspx session

Posted on 2010-11-15
3
Medium Priority
?
677 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:
Alfred A. earned 2000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

916 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