You can create a <div>
(or any plain HTML element) in code behind with the HtmlGenericControl
class, and use that to wrap your ImageButton
any way you want. For example:
private void OpenImage()
{
foreach (string strFileName in Directory.GetFiles(Server.MapPath("~/img/")))
{
ImageButton imageButton = new ImageButton();
...
HtmlGenericControl div = new HtmlGenericControl("div");
div.Attributes["class"] = "my-class"; // or div.Attributes.Add("class", "my-class");
div.Controls.Add(imageButton);
Panel1.Controls.Add(div);
}
}