Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用asp.net在c#中的面板中显示运行时的图像_C#_Asp.net_Image - Fatal编程技术网

使用asp.net在c#中的面板中显示运行时的图像

使用asp.net在c#中的面板中显示运行时的图像,c#,asp.net,image,C#,Asp.net,Image,我想在c#运行时在面板中显示基于搜索查询的图像。它是一个web应用程序。我编写的用于在运行时显示图像的代码不起作用。这是密码 System.Web.UI.WebControls.ImageMap image = new System.Web.UI.WebControls.ImageMap(); image.ImageUrl = reader["image"].ToString(); // Take the path from the database Panel1.Controls.Add(im

我想在c#运行时在面板中显示基于搜索查询的图像。它是一个web应用程序。我编写的用于在运行时显示图像的代码不起作用。这是密码

System.Web.UI.WebControls.ImageMap image = new System.Web.UI.WebControls.ImageMap();
image.ImageUrl = reader["image"].ToString(); // Take the path from the database
Panel1.Controls.Add(image); // Display the image

代码工作正常,但图像未显示在面板内。

如果您愿意尝试其他方法,可以执行以下操作:


(您的面板可见,对吗?

图像呈现的是什么标记?如果它有
src
属性,它是否指向实际图像?请发布您的
面板
代码以及其中的任何内容。图像的路径是绝对路径(例如/images/small/001.jpg)还是相对路径(../small/001.jpg)?在任何情况下,都可以查看HTML代码,以查看ImageMap的HTML的准确程度rendered@codingstill这条路仍然是绝对的
var image = new HtmlGenericControl("img");
image.Attributes["src"] = reader["image"].ToString();
Panel1.Controls.Add(image);