如何在图像控件中显示图像 [英] how to show image in image control
本文介绍了如何在图像控件中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将图像保存在应用程序目录的temp文件夹中
我检索了该图像,并希望在asp.net的图像控件上显示该图像
但图片未显示
下面是代码
请帮助
i save my image in temp folder of application directory
i retrieve that and want to show that on image control of asp.net
but image not shown
here below is code
plz help
String fileName = FileUpload1.FileName;
int newlrmnsdf = fileName.Length;
int gdf = newlrmnsdf - 4;
string strwithoutEXT = fileName.Substring(0,gdf);
string currenttime = System.DateTime.Now.Minute.ToString() + "_";
string newFileName = strwithoutEXT + currenttime + ".jpg";
string actualFilename = currenttime + newFileName;
bool IsExists = System.IO.Directory.Exists(Server.MapPath("temp"));
if (!IsExists)
{
System.IO.Directory.CreateDirectory(Server.MapPath("temp"));
FileUpload1.SaveAs(Server.MapPath("~/temp/") + actualFilename);
}
else
{
FileUpload1.SaveAs(Server.MapPath("~/temp/") + actualFilename);
}
if (fileName.Contains(".pdf"))
{
//Image1.Visible = false;
// frame1.Attributes.Add("src", "http://localhost:50389/temp/" + actualFilename);
}
else
{
// frame1.Visible = false;
// string url = "http://localhost:50389/temp/" + actualFilename;
string path = Server.MapPath("~/temp/");
Image1.ImageUrl = path + actualFilename;
}
推荐答案
问题已解决,无需进行图像控制
而不是使用iFrame在其中分配iframe源,即
iframe1.src =
problem solved no need to take image control
rather use iFrame in which assign the iframe source i.e
iframe1.src=
"~/temp/"+actualFilename
这篇关于如何在图像控件中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文