setlio
setlio

Reputation: 726

Assign class to Html.BeginForm

I am using Html.BeginForm but when trying to assign to it a class there is a problem. If i use class for the fourth place is fine. But if i try to use enctype in addition, there is a error. This is fine:

@using (Html.BeginForm("Edit", "Inventory", FormMethod.Post, new {enctype = "multipart/form-data"}))

But this is not:

@using (Html.BeginForm("Edit", "Inventory", FormMethod.Post, new {enctype = "multipart/form-data"}, new { @class = "listForm" } ))

And this is not:

@using (Html.BeginForm("Edit", "Inventory", FormMethod.Post, new { @class = "listForm" },  new {enctype = "multipart/form-data"}))

Any ideas please. Thank you

Upvotes: 3

Views: 1975

Answers (1)

WannaCSharp
WannaCSharp

Reputation: 1898

@using (Html.BeginForm("Edit", "Inventory", FormMethod.Post, new { @class = "listForm", enctype ="multipart/form-data" }) Try that

EDIT:

enctype and class are both htmlAttributes so you should place them in one anonymous object.

Upvotes: 7

Related Questions