我有一個形象的問題我有一個圖像是在根目錄下,如「C:\ MH \ mahesh1」,並試圖通過以下方式上載,但不會工作。圖像的Asp.Net Web應用程序
Defaults.aspx.cs
namespace UITI
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string img = MapPath("~Mh/mahesh1.jpg");
myimages.ImageUrl = img;
}
}
}
Defaults.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UITI._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="myimages" runat="server" BorderStyle="Double" />
</div>
</form>
</body>
</html>
我也試着像Default.aspx.cs頁:
namespace UITI
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string img = ResolveClientUrl ("~/Mh/mahesh1.jpg");
myimages.ImageUrl = img;
}
}
}
怎麼辦?
見我下面編輯的代碼,並嘗試 – 2013-03-07 08:04:57
沒關係嘗試this.Dont把任意文件夾name.See我的新編輯 RESOLVEURL(「mahesh1.jpg」) – 2013-03-07 08:21:04
好.Rename您mahesh1圖像,然後再試一次..請看到我後您的問題 – 2013-03-07 09:23:27