0

I separate the css from the *.aspx file. When this

background-image: url('<%=Page.ResolveUrl("~/Themes/Red/Images/Contestant/1.jpg)%>';)

was in the aspx file it worked, and now it's not working.

do you know any other way ?

1
  • the path in the css file can be relative to its location. E.G. css in "/css/" can refer to "/images/test.jpg" with "../images/test.jpg" Commented Apr 10, 2013 at 7:57

2 Answers 2

3

The scriptlet and ~ here is specific to aspx file and could not be used in css.

Change

background-image: url('<%=Page.ResolveUrl("~/Themes/Red/Images/Contestant/1.jpg)%>';)

To

background-image: url('/Themes/Red/Images/Contestant/1.jpg')

The above assumes the Themes folder is at root your your site.

To give path relative to css

background-image: url('Themes/Red/Images/Contestant/1.jpg')
Sign up to request clarification or add additional context in comments.

2 Comments

What is relative path of image from root?
if asp net project hosted in IIS, and is not default but a sub directory, how can the path be programmaticcly set. ASP Net used the ~/ to resolve this, but only works on asp.net pages. this issue looks to still be the case with visual studio 2013 web projects, and i have not been able to find solution yet, except have to change the css each time i deploy to a new site. url example would be root_site.com/myproject21/images/favicon.png in css url('/images/favicon.png') we resolve to root_site.com/images/favicon.png which is not where it is. any help?
0

this is what fix my problem

background: url(../../../image.png)

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.