使用asp.net在c#中的面板中显示运行时的图像
我想在c#运行时在面板中显示基于搜索查询的图像。它是一个web应用程序。我编写的用于在运行时显示图像的代码不起作用。这是密码使用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
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);