Reputation: 23159
in asp.net, I'm trying to generate an image tag with:
var img = new HtmlGenericControl("img");
it seems to generate <img></img>
How would I generate a normal image tag with asp.net/C#?
e.g.
<img/>
Upvotes: 2
Views: 3500
Reputation: 11238
There's a specialized html control for the image element.
System.Web.UI.HtmlControls.HtmlImage
which generates the html you want.
Upvotes: 6
Reputation: 17010
Override the rendering method and use HtmlTextWriter.SelfClosingTagEnd to create a self closing tag?
Upvotes: 1
Reputation: 3156
You are creating it as a generic html control. Try using the Image control:
var img = new Image();
Upvotes: 1