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 specify the previous params? I don't want to override the default action/method values
2 Answers
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.
1 Comment
Stefano
I found that passing in the params null apply the default values... Thank you anyway