繁体   English   中英

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

[英]Displaying images at run time inside a panel in c# using asp.net

我想在运行时在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

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

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

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

(您的面板可见,对吧?)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM