ASP.NET image control does not show the image
I am using an image control, but it does not display any image. When I see its viewsource, it displays the image path correct. The URL of the page is 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_" + strOriginalFi开发者_如何学GoleName + "_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;
}
Please help me as soon as possible.
you shouldn't use as server.mappath
ImgNews.ImageUrl = "~/ENewsImage/" + iNewsID + "_1" + Extension;
would be enough.
I think you have the wrong URL.
When you do :
String testURL = Server.MapPath("~/ENewsImage/" + iNewsID + "_1" + Extension);
Response.Redirect(testURL);
Is your image there? Make sure the URL is correct by printing it to the screen or visiting it.
精彩评论