Solved

asp.net dynamic master page pulls in its aspx session

Posted on 2010-11-15
3
644 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
Comment Utility
?
0
 
LVL 21

Accepted Solution

by:
Alfred1 earned 500 total points
Comment Utility
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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.…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now