62,074
社区成员
发帖
与我相关
我的任务
分享
<body>
<form id="form1" runat="server">
<asp:ImageButton ID="ImageButton1" runat="server" />
</form>
</body>
protected void Page_Load(object sender, EventArgs e)
{
string strBaseUrl = string.Empty;
string strSitePath = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
string strAppPath = HttpContext.Current.Request.ApplicationPath;
if (strAppPath == null || strAppPath == "/")
{
strBaseUrl = strSitePath;
}
else
{
strBaseUrl = strSitePath + strAppPath;
}
string strImageUrl = strBaseUrl + @"\image\a.jpg";
this.ImageButton1.ImageUrl = strImageUrl;
}