problem in path

Hi

I am working on asp.net web application. The project structure is

images
       header.jpg
shared
       default.master
module
        home.aspx
default.aspx

Description
1. There are three folders images, shared and module.
2. Inside the images folder there is an image called header.jpg,
3. inside the shared folder there is a file called default,master
4. Inside the module folder there is a file cllaed home.aspx
5. There is one file default.aspx at the root of the application

Inside the master page I have created a <div> like

<div style = "background : url(images\header.jpg)></div>

Now I am using the master page in both the aspx file i.e. home.aspx and default.aspx. But in default.aspx I can see the image but in home.aspx I can't see the image.

How to fix this issue?

Regards
Karan Gupta
KaranGuptaAsked:
Who is Participating?
 
mayank_joshiConnect With a Mentor Commented:

this should work anywhere in the entrie application:-

<div style = "background : url(<%=Page.ResolveUrl("~/images/header.jpg")%>)></div>

Open in new window

0
 
gavsmithCommented:
try using:

background:url('./images/header.jpg');

regards
0
 
gavsmithCommented:
Opps sorry, correction on mine, it shouldn't have the full stop at the beginning it should have been:

background:url('/images/header.jpg');
0
 
mayank_joshiCommented:
sorry the first method will not work,  the below method should work:-

<div style = "background : url('<%="http://" & Request.Url.GetComponents(UriComponents.HostAndPort, UriFormat.UriEscaped) & ResolveUrl("~/images/header.jpg")%>')">
Content Here
</div>

Open in new window


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.