CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 4/6/2008 7:21:53 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 6 Views: 21 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
7 Items, 1 Pages 1 |< << Go >> >|
SonicImaging
Asp.Net User
Nested MasterPage help...4/6/2008 7:21:53 PM

0/0

 Hi,  I need some help understanding nested master pages.   From reading I understand why you would do this but I think my requirement is a bit different.

 I have a single solution in VS 2008 using themes, a root master page and misc content pages,  This solution is setup to allow me to deploy a number of websites using the same code, but different database content, different database connections and so on.  all of the logic of these sites is the same, its the layout that needs to be different.  I setup a theme folder for each website using the websites name.   For development I have a app setting for the name of the site I want to run at that time and then I change the global theme based on this setting.

The next thing I want to do is keep the root master page that contains all the coding for the site in the code behind ( so i dont have duplicate code), but what is different for each site is the site layout.  so I was thinking on using a nested masterpage that is changed based on my appsetting in the web.config file.  I can name the 2nd master page  website1.master, website2.master and they will have a matched theme with the same name.

 So at runtime I get the value of the website name in app settings, set the global theme then set the root masterpage to grab the layout from my 2nd masterpage located in a folder on the site.  From here I want to be able to run a content page and have it displayed inside.

Ive already setup 2008 deployment that allows me to only copy the files I need for each site and the webconfig settings for that site to deploy the sites individually.  Thats great for deployment but I want to be able to run the different sites in my development environment based on the app setting.  This is how the project looks

MyProject
.....App_Code
.....Bin
.....App_Themes
..........Site1Theme
...............default.css
...............default.skin
...............web.config - specific settings for this site, connection strings, email etc
...............default.master - specific layout for this site
.....Site2Theme
default.aspx
default.master - no layout just site logic
web.config - config info for all sites
 

The web.config and default master are in the theme folder just so everything is in one place,  if this cause compile issues I can move them elsewhere. 

Am I making sense here?  if I create say an about page in the root, I want it to automatically use the master page from the site im running based on the appsetting in the root web.config file.

Thanks
   -Keith
 


My Site PopcornSupply - popcorn machines
ASP.NET 2.0, ASP, SQL server development
mpaterson
Asp.Net User
Re: Nested MasterPage help...4/6/2008 10:37:51 PM

0/0

I would create an appSetting in web.config for which masterpage to use.

then in your page_preInit set the Page.MasterPageFile property to the file name of the appropriate master page.

You will have to make sure that your master pages all have the same contentPlaceholders to do this, though.


If everything happens for a reason what is the reason for this error?
Amanda Wang - M
Asp.Net User
Re: Nested MasterPage help...4/8/2008 6:17:00 AM

0/0

Hi,

We can use the @ Page directive like this :  <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" Title="Untitled Page" %>

And you also can specify master page files for our web forms in the web.config file, for example: <pages masterPageFile="myMaster.master" />

But when you want to set the master page programatically, you need to just use the PreInit event, set the master page in the page's PreInit event event:

protected void Page_PreInit(object sender, EventArgs e)
{
  MasterPageFile =
"~/foo";
}

That;s because the master page has to rearrange the page?s control hierarchy before the Init event fires.

The master page will not apply for the content page when you switch the theme for the page, as you put the master page in the theme folder of the app_theme folder.  You should specify the master page for the content page.

the more about the master page, you can refer these greate articles:

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
SonicImaging
Asp.Net User
Re: Nested MasterPage help...4/8/2008 11:26:12 AM

0/0

 Great thanks for the extra info,   I finally got the nested master pages for each site setup and I was looking for a way to prevent me from having to add the code to each content page on the site.  The article from odetocode helped me setting up the base class for the page and now I can put all the logic in one place.  Thats what I was looking to do. Thanks

Having The master page in the theme folder was just to have a common place for it, but I got the "cant put anything else in the theme folder error".  I ended up making a 2nd folder named sites, with a folder for each site.  So there ive put the custom master page, config file changes for each site and setup both the master page and the theme in the pre_init base class.   It works wonderfully and now I have a layout for each site then all the code is in the parent master page.... ;)

At first I kept getting a error number 1 when I created the nested master page in another folder but if I create it in the same directory as the parent then move it, I dont get the error number 1.

Now I just need to be able to change the LINQ connection string at runtime and make my changes to my web deployment projects to make the config changes and move only the files used for each site.

Getting closer and what a time saver!!

Thanks

-Keith 

 


My Site PopcornSupply - popcorn machines
ASP.NET 2.0, ASP, SQL server development
Dave Sussman
Asp.Net User
Re: Nested MasterPage help...4/9/2008 5:14:14 PM

0/0

You can get away with creating base pages too if that's a route you're not keen on. You can use events in global.asax to set both the Theme and the Master page dynamically. See http://blogs.ipona.com/davids/archive/2008/03/30/8482.aspx.

SonicImaging
Asp.Net User
Re: Nested MasterPage help...4/9/2008 10:04:39 PM

0/0

 Yea I started with the base page but figured that more things to add to each page,  thanks for that link!! I set my theme and master page in the global.asax and thats working perfectly!!

Thanks

-Keith 


My Site PopcornSupply - popcorn machines
ASP.NET 2.0, ASP, SQL server development
Dave Sussman
Asp.Net User
Re: Nested MasterPage help...4/9/2008 10:06:30 PM

0/0

Using a base page is a good idea if you have lots of other things you want as part of your page, but for something simple I prefer the global event. It's just less work.

7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
ASP.NET 2.0 MVP Hacks and Tips Authors: David Yack, Joe Mayo, Scott Hanselman, Fredrik Normén, Dan Wahlin, J. Ambrose Little, Jonathan Goodyear, Pages: 400, Published: 2006
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Pro ASP.NET 2.0 Website Programming Authors: Damon Armstrong, Pages: 641, Published: 2005
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
ASP.NET 2.0 Black Book: black book Authors: Dreamtech Software, Dreamtech Software, Charul Shukla, Anil Kumar Barnwal, Dreamtech Software India, Pages: 1167, Published: 2006
Programming Visual Basic 2005 Authors: Jesse Liberty, Pages: 548, Published: 2005
Mastering InDesign CS3 for Print Design and Production: for print design and production Authors: Pariah S. Burke, Pages: 492, Published: 2007
Indesign Type: Professional Typography with Adobe InDesign CS2 Authors: Nigel French, Pages: 270, Published: 2006

Web:
VS 2008 Nested Master Page Support - ScottGu's Blog The good news is that VS 2008 fully supports nested master pages, ... To help with this blog post, I picked one of the templates that I thought looked nice. ...
Tips for Nested Master Pages and VS 2005 Design-Time - ScottGu's Blog i need help i have nested master pages, actually i have tryed it on the sample project on this site even. okay so i have the nested master pages from this ...
Nested Master Pages Below are a couple of sample codes which will help you in better understanding of the concept of Nested Master Pages and how to implement it? ...
Nested ASP.NET Master Pages Master pages can be nested, with one master page referencing another as its master. Nested master pages allow you to create componentized master pages.
Creating a Nested Master Page Dec 6, 2006 ... Creating a Nested Master Page. ... Before we look at the nested master pages, it may be instructive to look at a single master shown ...
CodeGuru: ASP.NET Tip: Using Nested Master Pages Sep 15, 2006 ... To implement a nested master page, you create a "root" master page for general use in the site. Here's an example: ...
CodeProject: Nested Master Page in VS 2008. Free source code and ... Feb 8, 2008 ... In visual studio 2008 nested master page concept is introduced, to make page template; ... Password Remember me? help Lost your password? ...
Creating Nested Master Pages Sep 22, 2005 ... NET 2.0 Free Tutorials : Creating Nested Master Pages - In this ... build and example nested master page with the help of sample code. ...
ASP.NET 2.0 : Creating Nested Master Pages In this tutorial you will learn how master pages can be nested within one main master page, build and example nested master page with the help of sample ...
CodeProject: Inheritance and Nested Master Pages. Free source code ... BTW: VS 2008 Beta 2 seems to be ok and handles nested master pages visually well Smile .... You obviously didn't need my clumsy attempt at help! Smile ...




Search This Site:










subdomain site: master page not working

css design not applied

menu rendering problem- no spacing

"object reference not set for object instance" and trying to overwrite default dynamic content with a master page

help in programatically generating and displaying menu controls

template in aspx

dynamically selecting master pages

tilde symbol ~ not working after url rewrite

tree view control (postback)

problem with master pages

how can i access a contentplaceholder??

how come the css style dosn't show in designer

apply theme with vb codefile.

multiple themes..menus constatly downloading images

validation of viewstate mac failed / the state information is invalid for this page and might be corrupted

menu control on master page

accessing methods from a dll file

masterpages with iframe

master pages - contentplaceholder control size in visual studio 2005 design mode

exactly one <sitemapnode> element is required directly inside the <sitemap> element.

dynamicmenuitem css problem

how, if possible, can i make the background color of a table cell "semi transparent"?

sitemappath and server.transfer woes

dynamically changing image as a menuitem

dynamically loading top level masterpagefile

problem with updating the <meta> 'description' and 'keywords' and <title></title> in masterpage from textbox in formview,

how to create dynamic menu from database

multiple sitemap providers

is it possible to get a treeview node value from the master page?

use sitemap controls for hierarchical links page

  Privacy | Contact Us
All Times Are GMT