Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Would you please tell me where will i put my image to get access in css sheet in asp.net programming ?
Posted

You can create a folder inside user project as 'Content' and then create another folder inside the 'Content' folder as 'Image' and put your images there and access those images from CSS is as below.

C#
#loadingDiv
   {
     background: url(/content/images/loading.gif) no-repeat;
   }
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 6-Nov-13 9:31am    
First '/' does not look right. You should better use relative path, for compatibility and other reasons.
Please see my answer...
—SA
Sampath Lokuge 6-Nov-13 9:50am    
This is also the relative path.It's relative to the root folder of the site (e.g. /images/logo.png).If you use it without leading slash (e.g. images/logo.png),then that path is relative to the CSS file.I think I'm right :)
Sergey Alexandrovich Kryukov 6-Nov-13 10:00am    
Ah... It turns out that you are right about "/..." as a site's root, I tested it. Sorry for my confusion. I'm up-voting your answer by my 5 and already corrected my answer, please see.
—SA
Sampath Lokuge 7-Nov-13 1:30am    
Yep,Thanks Sergey :)
You can put the files in any directory (or directories), as soon as they all are put under the root directory configured for your site. Usually, Web applications are executed under an HTTP server in a sandboxed environment, so they cannot access anything beyond this root directory.

By many reasons, it's the best to access the file using relative paths. For example, "../../images/myImage.png", "images/backgrounds/cloudySky.png", "./images/backgrounds/cloudySky.png", and so on. I hope you know path syntax and semantic. :-)

—SA
 
Share this answer
 
v4
Comments
Sampath Lokuge 7-Nov-13 1:31am    
+5,Nice one :)
Sergey Alexandrovich Kryukov 7-Nov-13 1:34am    
Thank you, Sampath.
—SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900