学习MVC时,学会了写扩展方法,用起来很方便。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
namespace MvcApp1.Content
{
//<%@ Import Namespace="MvcApp1.Content" %>
public static class MyHtmlHelper
{
public static string RedLable(this HtmlHelper helper, string lbstr)
{
StringBuilder sb = new StringBuilder();
sb.Append("<span style='color:red;'>");
sb.Append(lbstr);
sb.Append("</span>");
return sb.ToString();
}
}
}
粤公网安备44011402001581号