Custom html attributesi in Html.BeginForm
I know that in the html helper BeginForm available in asp.net mvc there is a param called htmlAttributes. How can I use it witouth specif开发者_运维百科y the previous params? I don't want to override the default action/method values
You could do something like this:
@using(Html.BeginForm(ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString(), FormMethod.Post, new{title = "title"}))
{
...
}
which outputs:
<form action="/" class="someclass" method="post">
</form>
It's not exaclty what you wanted and it's not pretty. You do have to specify the FormMethod.
Or add the attributes you need via jQuery.
Passing null as the value of the BeginForm function will apply the default params value
精彩评论