无法显示图像用户控件 [英] Unable to show image in usercontrol

查看:176
本文介绍了无法显示图像用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临由于2-天的问题,我有它只是有我保存在我的项目图像的用户控件。我已经提供了正确的路径给它仍然是不可见的图像。我使用Chrome的开发者工具,以检查问题,它给我

I am facing an issue since 2 days, I have a user control which simply has I have Images saved in my project. I have provided proper path to it and still it is not showing that image. I used Chrome's developer's tool to inspect the issue and it give me

src="/images/Uploads/home_banner1.jpg"

当我右键点击SCR和在新标签中打开链接,URL看起来像本地主机/图像/上传/ home_banner1.jpg这意味着它正试图找到根的图像图像/ ....文件夹中,对吗?我相信我有一个形象的存在具有相同的名称,但仍网页说,资源不能被发现。意味着404错误。我删除图像的名字从URL和pressed进入,它显示该文件夹中的所有文件,即使点击目录下的文件时,它仍给404错误后,这是什么,如何解决,没有跨越任何一个人来?我ahve很多在我脑海里的问题,请帮我解决这个问题。

when I right clicked on scr and opened link in new tab, url looked like localhost/images/Uploads/home_banner1.jpg that means it is trying to find image in root's images/.... folder, right? I am sure I have an image there with the same name but still webpage says,"The resource cannot be found." means 404 error. I removed image name from url and pressed enter and it shows all files in that folder, even after clicking file under directory it still give 404 error, what is this, how to solve, did any one came across it? I ahve lot of questions in my mind, please help me solve this.

修改

我已经解决了它('妥协'将是更好的词,而解决)。我把相同的图像不同的文件夹中,意味着问题一定是别的东西它运行良好,这是从来没有与该文件夹的安全性问题。我知道这是乏味纠正这个,但仍,如果有人面对和纠正一样,你可以分享你怎么这样做了。我得到更好奇,找出原因更改文件夹没有工作给我吗?

I have solved it ('compromised' would be better word rather 'solved'). I placed same images in different folder and its running fine, It was never an issue with security of that folder means problem must be something else. I know it is tedious to rectify this but still if someone faced and rectified the same, you could share how you did so. I am getting more curious to find out why changing folder did work for me?

谢谢大家。

推荐答案

我重新场景为你解释,似乎因为它预期将工作...
以下是用户控件...

I recreate the scenario as you explained and it seems to be working as it was expected... Following is the user control...

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="WebApplication1.WebUserControl1" %>
<img src="images/uploads/home_banner1.jpg" />

和下面是页面...

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="uc1" TagName="WebUserControl1" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:WebUserControl1 runat="server" id="WebUserControl1" />
    </div>
    </form>
</body>
</html>

只是你的HTML缺什么比较...

just compare with your html what is missing...

这篇关于无法显示图像用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆