Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Few CSS questions
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01530195
Message ID:
01530877
Views:
53
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>In ASP.NET MVC project I added an image in Images folder (I created that folder). I'm trying to do this in the site.css
>
>h1 {
>    font-size: 2em;
>    padding-bottom: 0;
>    margin-bottom: 0;
>    background-image: '~/Images/ChangeInfo.jpg';
>}
>
>However, I don't see my image at all. Do I reference this image correctly?
>

No. The ~ tilde reference only works inside particular places of the code, not in the CSS page. It's basically a shortcut for ASP.NET to tell it to resolve the URL at runtime. CSS/CSS files aren't evaluated by ASP.NET at runtime.

The path for the image is referenced relative to the current "folder" you are in. So normally you'll use an absolute path here: background-image: '/Images/ChangeInfo.jpg' so that the image works regardless of what the current path is.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform