Abid Ali
Abid Ali

Reputation: 1747

How to Set bg Image in asp.net

i am not able to show bg image on my web page. I have written a css which has the following code:

    body 
{
    background-image:url('E:\WEB WEB WEB WEB\RedRockNoodleBar\RedRockNoodleBar1\RedRockNoodleBar1\Images\outer_bg.jpg');
    background-repeat:repeat-x;
}

The css is applied in the design view of the master page. when i add a content page and run the program, the web page is empty. and shows nothing. y is it so?

Upvotes: 0

Views: 1440

Answers (3)

kleinohad
kleinohad

Reputation: 5912

try

background-image:url('file:///E:/WEB WEB WEB WEB/RedRockNoodleBar/RedRockNoodleBar1/RedRockNoodleBar1/Images/outer_bg.jpg');

Upvotes: 1

Luke Duddridge
Luke Duddridge

Reputation: 4347

I wouldn't reference the physical location via a drive... what happens If I dont have an E drive?

As you are building a website, you can reference a virtual location of the image, if your E drive location isn't part of your site then create a virtual directory within your site, so that it is.

Upvotes: 1

Paolo Falabella
Paolo Falabella

Reputation: 25844

you should put the virtual path to your image in your CSS, not the physical path.

something like

body 
{
    background-image:url('../Images/outer_bg.jpg');
    background-repeat:repeat-x;
}

but it depends on where your CSS file is located relative to your Images folder. Here I'm assuming your web app has a structure like this

---Style (folder)
   \--Stylesheet.css

---Images (folder)
   \--outer_bg.jpg

---Default.aspx

Upvotes: 3

Related Questions