我的图像有问题 我有一个图像,它位于“C:\Mh\mahesh1”之类的根目录中,并尝试通过以下方式上传,但无法正常工作。
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;
}
}
}
怎么做?。