Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/1/30 1:28:29
GridView显示服务器图片(保存为图片路径)_[Asp.Net教程]

GridView显示服务器图片(保存为图片路径)_[Asp.Net教程]
//前台页面创建显示图片列




’ runat="server" /> (注:后台方法名用来得到服务器中全路径)





或者2:


显示图片


" target="_blank">"
alt="" width="20px" height="20px" />








后台代码:

//获取图片
protected string GetImg(string img)
{
string imgurl = ImageURL + img; 注:ImageURL为服务器保存图片文件夹的路径
return imgurl;
}

public static string ImageURL {
get {
string imageurl = ConfigurationManager.AppSettings["ImageURL"].ToString()+"/";
if (imageurl != null) {
return imageurl;
}
return "";
}
}

或者2(显示的图片点击可链接到对应的图片地址):

public static string GetImagePath()
{
return ConfigurationManager.AppSettings["ImageUrl"].ToString();
}


If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759