Solved

asp.net dynamic master page pulls in its aspx session

Posted on 2010-11-15
3
667 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

636 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