Click here to Skip to main content
11,924,707 members (46,152 online)
Click here to Skip to main content
Add your own
alternative version



Relative Path Solution for Master Pages

, 20 Feb 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
A relative path solution for master pages.

If you are having issues with your web pages not displaying background images and you are using a masterpage, the problem could be because the path to the image is relative to the page itself and not the masterpage.

To fix this issue, add a link to a CSS file in your masterpage instead of using inline styles.

<link href="css/Main.css" rel="stylesheet" type="text/css" />

This makes the image path become relative to the linked CSS file instead of the page.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer JBH Works
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralReason for my vote of 1 This will not work in url rewrite pa... Pin
Mukund Thakker22-Feb-12 18:46
memberMukund Thakker22-Feb-12 18:46 
GeneralYou can use the full url, if you have url rewrite. &lt;link ... Pin
Mukund Thakker22-Feb-12 18:44
memberMukund Thakker22-Feb-12 18:44 
You can use the full url, if you have url rewrite.
<link href="http://localhost/website/CSS/Main.css" rel="stylesheet" type="text/css" />
GeneralYes that is another solution but I disagree that you should ... Pin
FrostedSyntax21-Feb-12 20:21
memberFrostedSyntax21-Feb-12 20:21 
GeneralReason for my vote of 1 maybe a solution could be ALWAYS AVO... Pin
giammin21-Feb-12 3:56
membergiammin21-Feb-12 3:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151125.3 | Last Updated 20 Feb 2012
Article Copyright 2012 by FrostedSyntax
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid