开发者

HtmlGenericControl("img") not generating proper image tag

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 i开发者_运维问答mage tag with asp.net/C#?

e.g.

<img/>


There's a specialized html control for the image element.

System.Web.UI.HtmlControls.HtmlImage

which generates the html you want.


You are creating it as a generic html control. Try using the Image control:

var img = new Image();


Override the rendering method and use HtmlTextWriter.SelfClosingTagEnd to create a self closing tag?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜