开发者

Is it possible to add an attribute to HtmlTextWriter WriteBreak

开发者 https://www.devze.com 2023-01-02 08:51 出处:网络
Is it possible to add a class to a br 开发者_C百科tag when using the HtmlTextWriter.WriteBreak method?

Is it possible to add a class to a br 开发者_C百科tag when using the HtmlTextWriter.WriteBreak method?

writer.AddAttribute(HtmlTextWriterAttribute.Class, "className");
writer.WriteBreak();

I need an xHtml compliant html output and therefore the WriteBreak is perfect as it writes

<br />

I want to add a class to the br so that I have

<br class="className" />


You can do it manually, like this:

writer.WriteBeginTag("br");
writer.WriteAttribute("class", "className");
writer.Write(HtmlTextWriter.SelfClosingTagEnd);
0

精彩评论

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