0

我想在 C# 运行时根据面板内的搜索查询显示图像。它是一个网络应用程序。我为在运行时显示图像而编写的代码不起作用。这是代码。

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

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

4

1 回答 1

0

如果您愿意尝试其他方法,您可以这样做:

var image = new HtmlGenericControl("img");
image.Attributes["src"] = reader["image"].ToString();
Panel1.Controls.Add(image);

(你的面板是可见的,对吧?)

于 2013-11-03T06:43:33.993 回答