简体   繁体   English

将图像从母版页加载到内容页时出错

[英]Error in loading the image from master page to content page

I have created an asp.net application with a master and a content page. 我创建了一个具有母版和内容页面的asp.net应用程序。 My master page contains buttons and images which are also to be displayed in the content page. 我的主页包含按钮和图像,这些按钮和图像也将显示在内容页面中。 But I am only getting the buttons, but no images (images are present in both header and footer). 但是我只得到按钮,但是没有图像(图像出现在页眉和页脚中)。 Can you suggest a solution to this? 您可以提出解决方案吗?

What are the URLs of your images? 图片的网址是什么? How are you linking to them? 您如何链接到他们? If you are calling them relative, and if your master page and your content pages are in different paths or path levels, your content pages might not be getting the correct URLs to the images. 如果您称它们为亲戚,并且您的母版页和内容页位于不同的路径或路径级别,则您的内容页可能无法获得正确的图像URL。

Example: 例:

If your master page is in "/MasterPage/master.master" and your content pages are in "/Pages/PageType1/page.aspx", and your master page has 如果您的母版页位于“ /MasterPage/master.master”中,而您的内容页位于“ /Pages/PageType1/page.aspx”中,并且您的母版页具有

<img src="../images/sample.jpg">

Your page content will be looking for the image in "/Pages/images/sample.jpg", which will be wrong. 您的页面内容将在“ /Pages/images/sample.jpg”中寻找图像,这是错误的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM