2

I have a webdev problem

I have close to 10,000 serverside pages, all of thse use the same stylesheet. I have created a new serverside page which is like a dynamic menu system to help find specific pages from the existing 10,000 pages quickly and easily.

The problem is, that if the serverside pages are accessed the old way using the old menu system, they should retain their old stylesheet. however, if they are accessed via the new menu system, they should use a new refreshed stylesheet.

Editing 10,000'ish pages does not seem like a good option. What is the best way to go about tackling this problem?

11
  • in case of php i will make one file and inlcude in all pages , then change in one page reflect in all pages. Commented Jun 1, 2011 at 9:42
  • Hi Oshirowanen. Would you be able to clarify something. Are the old and new pages built to different specifications. ie. Are they using different template types etc, are all of these pages be using the same templates/master_page. Also, are they all being served up, (both old and new) from the same domain? Sorry, but I couldn't get exactly what you wanted from the question. Do you have some examples of both page types perhaps. Good luck! Commented Jun 1, 2011 at 9:47
  • how you can find whether request is coming from old menu or new menu Commented Jun 1, 2011 at 9:48
  • @BizNuge. The old pages are created with .net 1 so I don't think master pages existed back then. The new menu is created with .net 3.5. They are both from the same server, but the domain names are a little different, e.g. mysite1.com has the 10,000 pages plus the old menu, and mysite2.com has the new menu. Commented Jun 1, 2011 at 9:54
  • in that case could you not simply provide differing css themes per domain (sorry I actually use Java/PHP so have only limited knowledge of .NET web servies). I'm assuming here that you have access to the templates to edit, and that you might be referencing this css relatively (that may be too many assumptions to be honest). Another solution, might be to simply sniff the domain location with some JS and then include whatever css you require based on that (although, again, I'm assuming you have some control over the templates here, which you may not). Commented Jun 1, 2011 at 10:30

4 Answers 4

2

Have the stylesheet in an app_themes folder and set this in the web.config. Then you can change between the two quickly. Or you could set this in code in the pre_init event

EDIT: 1: Add and app_themes folder, create two sub folders with theme names (eg, default or Blue etc)

2: either in the web.config set the or

3: catch the page_init for each page that you wish to change(or for master pages and lots of pages have a base page class and override page_init) and set the Page.Theme = to a theme you want. Best off saving this in Session State from what I can tell. So something like this:

 if (Session["Theme"] == null)
  {
    //the string is the theme as per the cleaners default
    string chosenTheme = selectedTheme();
    Session.Add("Theme", chosenTheme);
    Page.Theme = ((string)Session["Theme"]);
  }
  //if the page is reloaded.
  else
  {
    Page.Theme = ((string)Session["Theme"]);
  }

Hope this helps sire

Sign up to request clarification or add additional context in comments.

8 Comments

Could you please give more details about these 2 options. Possibly links to documentation?
Here's a discussion of themes, including setting them in web.config + an explanation of their precedence. I think this may be the way to go.
So basically, I can use themes to change style sheets based on how a webpage is requested, i.e. if 1 of the 10,000 pages is requested by old_domain.com/menu.aspx, use oldstyle.css for the 10,000 pages, if 1 of the 10,000 pages is request by new_domain.com/menu.aspx, use newstyle.css for the 10,000 pages. Can that be done?
@Daniel Casserly, Thanks for the step by step. Question 1, do I create the app_themes folder on the old domain or the new domain?
Erm sorry dont get you, do you mean in the visual studio environment?
|
0

If you can't write some global server side code nor have a global template for all the 10.000 pages, my first idea is to have a URL-Rewrite for the CSS file based on a specific url parameter. So you could have a 2nd CSS file which will be served if this parameter is submitted, if not the rewrite would serve the original css file.

1 Comment

I can write global serverside code, but how would I get it linked with the old 10,000 pages? Also, if I do use url-rewrite, how do I get the old 10,000 pages to recognise the change in the url without editing each and every 1 of those 10,000 pages?
0

Normally Id have suggested a URL rewrite, so that requests for the old styles are redirected to new. (IIS can do this, as an example : http://www.iis.net/download/URLRewrite )

5 Comments

If I do use url-rewrite, how do I get the old 10,000 pages to recognise the change in the url without editing each and every 1 of those 10,000 pages?
If your old file was say \menu.css, and new is \newmenu.css, you rewrite requests for \menu.css to \newmenu.css, instructions and info were on the link I added as an example, there are others for IIS. Its as good as doing a search and replace on your files with the new names.
So basically just to confirm, I can use iis url rewrite rules to create a rule which says, if old menu is used to access the 10,000 pages, use old style sheet, but if new menu is used to access the 10,000 pages, use new style sheet, even though both menus and 10,000 pages are on the same server, but the new menu has a different domain name.?
We're using iis6, apparently iis url rewrites started with iis7?
If you read round the page, I found forums.iis.net/t/1160436.aspx for example.
0

The following page might be useful to you Oshirowanen.

http://blogs.msdn.com/b/dotnetinterop/archive/2008/06/18/rewriting-urls-on-iis5-iis6-or-iis7-mod-rewrite-on-iis.aspx

I googled around for mod_rewrite style options for iis6 and this cropped up. It's from 2008 but seems to be at least around what you're looking for in the context of iis6 and would, I would hope, allow you to set up some kind of access rule that could possibly redirect clients on one of the domains to some new css folder/assets you specify.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.