can some on help me on how i can reference images i have all my images stored in an image folder which is located in the root folder (..\images) in my css class i have the the following
#image
{ background-position: left;
background-repeat: no-repeat;}
.background
{
background-image: url(..\images\image.gif);
}
and in my .cs file i have
image.Attributes.Add("class", "background");
image is a div tag which is in my aspx code !!
when i run this code i image doesnt show, any ideas what i might be doing wrong
You should turn those slashes in your paths around from
\to/Also, I usually put an
urlkeyword before the parenthesis in CSS, but I am not sure if this is required:UPDATE: If the
imagefield in your C# code is some kind of webcontrol, say anImagecontrol, you should use the setts on itsCssClassproperty rather than explicitly adding aclassattribute. What you are doing now might yield twoclassattributes in the markup, which might not get handled well. You can do a quick “view source” on your page to test if this is the problem.If this does not help, see Nick Cravers answers. The path from your CSS to the image is wrong, or the image file is not where you believe it is.