2011年7月2日 星期六

【MVC】自建 HTML Helper

1.新建一個資料夾,新增Class,取名ctlHelper.cs

2.ctlHelper.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;




namespace myApp.HTMLHelper
{
    public static class ctlHelper
    {
        public static string LaberHelper(this HtmlHelper helper, string args)
        {
            return "
" + args+ "
";
        }
    }
}


3.在 Views/*.aspx中引用
<%=Html.LaberHelper("姓名") %>

沒有留言:

張貼留言