master page images not showing on child pages
Asked Answered
D

9

7

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!

Depart answered 13/4, 2010 at 14:21 Comment(0)
D
21

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.

Devoice answered 13/4, 2010 at 14:28 Comment(0)
C
8

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"
Corwun answered 20/10, 2011 at 18:25 Comment(0)
E
4

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

Enid answered 13/4, 2010 at 14:27 Comment(0)
S
1

The URL to your image is incorrect.

Squint answered 13/4, 2010 at 14:24 Comment(1)
what id done was drag the image from the solution explorer to the form. I pulled in an asp:image and set the url, that did the trick, thanksDepart
E
1

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 =)

Enjoyable answered 13/4, 2010 at 14:27 Comment(0)
S
0

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.

Secundines answered 13/4, 2010 at 14:25 Comment(0)
A
0

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.

Applecart answered 21/2, 2015 at 20:15 Comment(1)
Isn't this for referencing images in a relative way? The ".." convention is simply for stepping up a folder level from your current page.Overcome
F
0

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 !!.

Federalize answered 16/3, 2016 at 22:13 Comment(0)
T
0

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.

Tigre answered 11/7, 2016 at 8:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.