简体   繁体   中英

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

I want to display images based on a search query inside a panel at run time in c#. Its a web application. The code i wrote for displaying images at run time is not working. Here's the code.

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

The code is working fine, but the image is not getting displayed inside the panel.

If you're willing to try something else you could do this:

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

(Your panel is visible, right?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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