ASP.NET MVC HtmlHelper用法大全

HTML扩展类的所有方法都有2个参数:

以textbox为例子

public static string TextBox( this HtmlHelper htmlHelper, string name, Object value, IDictionary<string, Object> htmlAttributes )

public static string TextBox( this HtmlHelper htmlHelper, string name, Object value, Object htmlAttributes )

这2个参数代表这个html标签的属性集合。使用方法如下。

1.ActionLink

<%=Html.ActionLink("这是一个连接", "Index", "Home")%>

带有QueryString的写法

<%=Html.ActionLink("这是一个连接", "Index", "Home", new { page=1 },null)%>

<%=Html.ActionLink("这是一个连接", "Index", new { page=1 })%>

有其它Html属性的写法

<%=Html.ActionLink("这是一个连接", "Index", "Home", new { ); %> 看清楚了没有等号的。