• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

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
0
KaranGupta
Asked:
KaranGupta
  • 2
  • 2
1 Solution
 
gavsmithCommented:
try using:

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

regards
0
 
mayank_joshiCommented:

this should work anywhere in the entrie application:-

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

Open in new window

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now