我有一个形象的问题我有一个图像是在根目录下,如“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