TagBuilder
Mvc
TagBuilder ToString()重载
ToString() <Lable id="test" style="color:blue">测试</Lable>
ToString(TagBuilder.Normal) <Lable id="test" style="color:blue">测试</Lable>
ToString(TagBuilder.StartTag) <Lable id="test" style="color:blue">
ToString(TagBuilder.SelfClosing) <Lable id="test" style="color:blue"/>
ToString(TagBuilder.EndTag) </Lable>
cs:
public static string Span(this HtmlHelper HtmlHelper, string id, string innerText) { var builder = new TagBuilder("span"); builder.GenerateId(id); builder.SetInnerText(innerText); return builder.ToString(TagRenderMode.Normal); }
html:
<span>22222</span>
解决方法:
只要把返回值修改为MvcHtmlString 就可以了。