namespace System.Web.Mvc
{
public static class MyHttpHelperExt
{
public static string MyLabel(this HtmlHelper helper, string txt)
{
return string.Format("<span>{0}</span>", txt);
} //这种方式MvcHtmlString会让我们代码不会被编码化,比如<script>alert('dd')</script>
public static MvcHtmlString MvcHtmlLabel(this HtmlHelper helper, string txt)
{
var str= string.Format("<span>{0}</span>", txt);
MvcHtmlString mvc = new MvcHtmlString(str);
return mvc;
}
}
}