Reference app relative virtual paths in .css file

Posted by bravo9 on Stack Overflow See other posts from Stack Overflow or by bravo9
Published on 2008-09-18T02:17:06Z Indexed on 2010/05/13 2:14 UTC
Read the original article Hit count: 432

Filed under:
|
|

Assume I have an "images" folder directory under the root of my application. How can I, from within a .css file, reference an image in this directory using an ASP.NET app relative path.

Example:

When in development, the path of ~/Images/Test.gif might resolve to /MyApp/Images/Test.gif while, in production, it might resolve to /Images/Test.gif (depending on the virtual directory for the application). I, obviously, want to avoid having to modify the .css file between environments.

I know you can use Page.ResolveClientUrl to inject a url into a control's Style collection dynamically at render time. I would like to avoid doing this.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about css