[英]ASP.NET image control does not show the image
我正在使用圖像控件,但是它不顯示任何圖像。 當我看到其viewsource時,它顯示正確的圖像路徑。 該頁面的URL為devweb.tsgdomain.com/americaneyenew/News.aspx
lblTitle.Text = dtNews.Rows[0]["NewsTitle"].ToString();
string strPhotosImage = dtNews.Rows[0]["Image"].ToString();
if (strPhotosImage != string.Empty)
{
string Extension = strPhotosImage.Substring(strPhotosImage.LastIndexOf("."));
// Server.MapPath("~/ENewsLetterFileUpload/NPH_" + strOriginalFileName + "_1.PDF");
ImgNews.ImageUrl = Server.MapPath("~/ENewsImage/" + iNewsID + "_1" + Extension);
//Server.MapPath("~/ENewsImage/" + iNewsID + "_1" + Extension);
//"../ENewsImage/" + iNewsID + "_1" + Extension;
ImgNews.Visible = true;
}
else
{
ImgNews.Visible = false;
}
請盡快幫助我。
你不應該用作server.mappath
ImgNews.ImageUrl = "~/ENewsImage/" + iNewsID + "_1" + Extension;
足夠了。
我認為您的網址錯誤。
當您這樣做時:
String testURL = Server.MapPath("~/ENewsImage/" + iNewsID + "_1" + Extension);
Response.Redirect(testURL);
你的形象在那里嗎? 通過將URL打印到屏幕上或訪問URL,確保URL正確。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.