开发者

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 开发者_Python百科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!


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.


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"


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


The URL to your image is incorrect.


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


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.


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜