DarkW1nter
DarkW1nter

Reputation: 2851

master page images not showing on child pages

This is probably something really simple but I cant see what! Any images I have in a masterpage aren't showing up in child pages, all I get is the box with the red cross in it.

I don't think Ive done anything different from usual and it's not something that's happened in other sites so im kinda scratchin my head with it. Any ideas are appreciated!

Upvotes: 7

Views: 22937

Answers (9)

k3ka
k3ka

Reputation: 111

If you use image<img> tag instead of this, please use "style="background-image: url('/Images/welc.jpg');"in any other tag. This looks like a silly.But it works for me. I was also getting this problem,after using this thereafter I got image at all my child pages.

Upvotes: 0

Ikram Khan
Ikram Khan

Reputation: 1

If Content pages are located inside subfolders this problem arises. When a content page is rendered the markup is generated afresh for the master page content as well, and the location of an image may render differently as it appears in the master page. The best way is to replace with asp:Image control instead of HTML image tag. Then define the absolute starting with:~/ to actual location of the image. This should solve the problem. Please remove the entire image tag before inserting asp:Image as attributes are different for both. Good Luck !!.

Upvotes: 0

Hema Shetty
Hema Shetty

Reputation: 109

If you set the right path then also you are getting the same problem then you can try this will definitely solve your problem:

Use double dots(..) before the starting of url.

Upvotes: 0

ranganadh
ranganadh

Reputation: 81

in the master page you use the image src similar to the below line and this will work. this same problem solved usig this way.

src="<%= Page.ResolveUrl("~")%>Images/myimage.png"

Upvotes: 8

Harper Shelby
Harper Shelby

Reputation: 16583

Kevin's got the essence of the problem right - your URL in your master page is likely relative to the location of the master page, and when it's included in the child page, the relative reference isn't correct anymore. The simplest solution for this sort of thing is to have your master page URLs be relative to the site, not the page. In other words, if you've been doing

<img src="images/picture1.gif">

You need to replace that with

<img src="/images/picture1.gif">

or something similar.

Upvotes: 21

Jens
Jens

Reputation: 25573

Try using absolute paths to your images.

I've had this problem when using a master file with content pages in different subdirectories. If you use relative paths to your images, thay should be relative to the content page, not the master.

Edit: This is true if you use the img tag to display your images. asp:Image behaves better =)

Upvotes: 1

graphicdivine
graphicdivine

Reputation: 11211

Did you give the image runat="server" and use a root relative "~/" path to the file?

Upvotes: 4

jaltiere
jaltiere

Reputation: 1118

It definitely sounds like you have a pathing problem. View the source to your rendered page and take a look at where it's trying to load the image from, that should help you fix your path.

Upvotes: 0

kemiller2002
kemiller2002

Reputation: 115508

The URL to your image is incorrect.

Upvotes: 1

Related Questions