我希望在运行时在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
代码工作正常,但图像未显示在面板内。
答案 0 :(得分:0)
如果您愿意尝试别人,可以这样做:
var image = new HtmlGenericControl("img");
image.Attributes["src"] = reader["image"].ToString();
Panel1.Controls.Add(image);
(你的面板是可见的,对吗?)