views:

379

answers:

4

I'm hoping my cryptic title isn't too cryptic, but I'll try to explain what it is I actually want to do.

I have a master page 'A' which has child pages 'B' and 'C'. This is implemented with the standard master page model in ASP.NET just fine.

My site has two themes 'T1' and 'T2'. They actually represent different partners, T1 being our own company and T2 is a partner.

I want to display specific things on pages 'B' and 'C' depending upon which theme I'm using. For instance I may want to insert additional buttons or graphics on page 'B' specific to partner for theme 'T2'. This content would be at an arbitrary point on the page depending upon the page itself. Some partners may not even use this feature.

The problem is I want to do this as declaratively as possible, and minimize the knowledge that the pages have about the theme.

This is where the 'reverse' master page concept comes in. I want to define an area on a child page into which 'theme' specific content can be inserted. (I'm saying 'theme' because thats what ASP.NET uses - and most likely what I'd tie the content to).

So you may be wondering :

  • Why can't you just use a master page for this and add extra content sections? Reason is that the content may appear anywhere on the page in a location that is specific to that page.
  • Why can't you use a 'nested' master page? Essentially the same reason.

Possible solution:

I'm wondering about creating some kind of user control that would have a textual key representing what type of content would be inserted there. The user control would have to know what to display for each 'theme' - probably by dynamically creating the relevant additional user control.

This seems a little clumsy - so I'm wondering what kind of solutions others may have created for similar situations.

A: 

Do you have fix layout for different partners ? Or do you want the partners to choose the layouts on runtime ?

If the layouts are fixed than 1 way is to create zen style CSS (http://www.csszengarden.com/) and than dynamically load it as per the client/partner. If you want the partners to modify the layouts on runtime than probably you might want to use Webparts.

Hope this helps.

Jomit
Webparts will really complicate your project/ pls try to avoid them. u dont want to end up with something that looks like Sharepoint *shudders*
cottsak
layouts are essentially the same. there'll b some overall graphical differences and programatic ones like different menus but essentially the same. currently i'm managing all the partners anyway. its mainly about additional content in arbitary (but known) places on the content pages
Simon_Weaver
hehe maybe i should just use sharepoint
Simon_Weaver
i'd stick with the programmatic changes like u said you're already doing. but use the CSS for graphic/layout differences.PS: dont use sharepoint. its evil (i know its impolite to post unsubstantiated remarks, but some things are known. satan is evil. sharepoint is evil)
cottsak
+1  A: 

you can use CSS to position your content sections anywhere on your page. so i wouldnt worry about page locations, etc.

if it were me, i'd just dynamically load the 2 different css files into the one masterpage and based on the same logic render the different content into the placeholders.

cottsak
A: 

I'm currently working on a site that has similar requirements that are too much for CSS. In one layout the login is horizontal towards the top of the render order, and in another its in the right hand column.

We're using standard ASP.NET themes to push out CSS, logo URLs via SkinID, etc.

To obtain the custom layout I've created a "Loader" control that loads UserControls via a list specified in a Loader attribute. The attribute can be defined directly in the loader markup, or via a .skin file in the theme.

Each key in the list is just the base name of a UserControl (I add the path and extension). The controls are created via Page.LoadControl().

devstuff
A: 

You CAN use nested master pages in VS2008!

See here --

Scott Guthrie's Blog

GeekyMonkey