ASP.NET MVC3 中设置htmlAttribute

直接上实例

假如有个表单,你需要设置表单中的输入框不自动记忆以前输入的内容时,一般的HTML中的写法是

<form autocomplete="off">
    <!-- 表单中的内容 -->
</form>

其中autocomplete是表单中的属性,那么在你用Html.BeginForm生成表单时,需要设置htmlAttrbutes参数,如下

@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { autocomplete = "off" }))
{
@*表单元素*@
}

其中new { autocomplete = "off" }就是htmlAttrbutes参数。

 

再例如

@Html.ActionLink("linktext", "actionName", new { routeValues = 1 }, new { title = "鼠标移入提示", target = "_blank" })

 

posted on 2012-08-01 15:04  leiOOlei  阅读(712)  评论(0编辑  收藏  举报