Html.BeginForm与HTML属性asp.net mvc4 [英] Html.BeginForm with html attributes asp.net mvc4
本文介绍了Html.BeginForm与HTML属性asp.net mvc4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 Html.BeginForm
编辑操作。如何添加HTML属性?
I have Edit Action with Html.BeginForm
. How can I add HTML attributes?
我知道只有一条路:
@using (Html.BeginForm("Edit", "Clients", FormMethod.Post, new { @class="example"})) {
}
但如果我用这个方法我无法通过电流ID
but if I use this method I cannot pass current ID
是否有可能添加HTML属性,形成不修改操作URL?
Is it possible to add HTML attributes to form without modifying action URL?
推荐答案
您所需要的倍率:
@using( Html.BeginForm("Edit", "Clients", new { Id=Model.Id},
FormMethod.Post, new { @class = "example" } ) )
{
}
- 路由值,如ID作为第三个参数传递。
- HTML属性,如阶级作为第五个参数传递。
请参阅 MSDN文档
这篇关于Html.BeginForm与HTML属性asp.net mvc4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文