0

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 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I found that passing in the params null apply the default values... Thank you anyway
0

Passing null as the value of the BeginForm function will apply the default params value

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.