Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys n gals

I am creating website which have admin i want to set background image of the pages,which are in admin module.

the code is as written below:
<body style="background-image:url(dbg.jpg);"  runat="server">

but I am not getting any image. please guide me.

Updated 19-Feb-11 0:48am
DaveAuld 19-Feb-11 6:50am    
Edit: removed random semicolon from end of tag content

The problem you may be facing is relative paths to the image.

Depending on where your document is located relative to the image things may not work as expected.

In CSS you cannot use the tilde (~) symbol to get the project root, i tried and it does not work, so you have to use root based paths using /.

I have also seen people hop up the tree using ../../ notation, but thing this is to risky and better to work root down.

<body style="background-image:url(/folder/folder/images/image.jpg)"  runat="server">

if you miss the leading '/' you end up with a relative path.
Share this answer
Sergey Alexandrovich Kryukov 19-Feb-11 22:43pm    
My 5: the issue it trivial but critically important to note.
If you are having image under Admin folder then
<body style="background-image:url(Admin/dbg.jpg)"  runat="server">
Share this answer
DaveAuld 19-Feb-11 6:46am    
This is true, but that is relative to the document, so if using master pages etc, this can still fail depending on you project structure. See my answer for an extended explanation.
Sergey Alexandrovich Kryukov 19-Feb-11 22:44pm    
Dave's right, still the answer's basically correct, my 4.

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