开发者

HtmlGenericControl("img") not generating proper image tag

开发者 https://www.devze.com 2023-03-11 18:20 出处:网络
in asp.net, I\'m trying to generate an image tag with: var img = new HtmlGenericControl(\"img\"); it seems to generate <img></img>

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

精彩评论

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