.net Core 中将原MVC中的 MvcHtmlString转换
时间:2019-02-18 14:16:29
收藏:0
阅读:533
public static IHtmlContent CustomLabelFor(this IHtmlHelper helper, Expression> expression, object htmlAttributes)
{
string result;
TagBuilder div = new TagBuilder("div");
div.MergeAttribute("class", "form-group");
var label = helper.LabelFor(expression, new { @class = "control-label col-lg-1" });
div.InnerHtml.AppendHtml(label);
using (var sw = new System.IO.StringWriter())
{
div.WriteTo(sw, System.Text.Encodings.Web.HtmlEncoder.Default);
result = sw.ToString();
}
return new HtmlString(result);
}
原文:https://www.cnblogs.com/yingger/p/10395279.html
评论(0)