![]() |
Nesting pages in folders.
In my aspx.net site my master page contains the links to all stylesheets. Whenever I try to put one of my pages that use that master page in a subfolder they look right html wise but none of the styling is passed over and all pictures in the master page don't appear either. I know this is a problem with how I'm linking to the stylesheet and the images but I don't know how to fix it. It's assuming that everything should be in the same folder as the page but that isn't the case...Has anyone else experienced this?
|
Why are you surprised?
If you have folders set up as Code:
/rootSo you either need to specify the correct *relative* path from your "another.aspx" file or you must specify an *absolute* path that is relative to the root of your site. If your /root directory (or whatever it is named, but corresponding to the above picture) is also your web root directory, then you can always get to "master.css" from *ANY* page by using "/css/master.css". That leading "/" means "start at the root directory". There are other solutions, especially if you control setting up virtual directories on the server, but that's the meat of it. |
I changed all the paths to have ../ in front of them in my master page. So then it worked for the sub pages but stopped working for the pages located under the root. Not sure why. So then I just created a different master page for any pages in a subfolder and it is working just how I want it. I just don't know if that is the best way to do it?
|
I'd have to see your folder structure to know.
|
this link kinda describes the idea... what you are dealing with is absolute vs relative paths (in your case you are doing relative)... I always find this to be a pain in the ***, and I have never cared to 'learn it'... I know the concept behind it, but what I do is (if) I am starting a new project, I get the skeleton working first with my master page and all the children, and then go to work on the rest of the site. Once you understand the theory behind it you can either learn it, or fiddle with it from time to time as I do.
basically it boils doen to this... absolute paths (which you are not using) would be something like this Code:
"C:\\inetpub\\wwwroot\\website1\\CSS\\MyStyles.css" orthen there are relative paths which looks like Code:
"./CSS/MyStyles.css" orhope that helps some |
Ok I see now. I'm still not sure why when I add the ../ it only works for some and not others. But I did solve the problem by using separate master pages
|
Quote:
|
Quote:
|
| All times are GMT +1. The time now is 02:27 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.