Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign class to Html.BeginForm

Tags:

c#

asp.net-mvc

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

like image 528
setlio Avatar asked Dec 05 '25 03:12

setlio


1 Answers

@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.

like image 183
WannaCSharp Avatar answered Dec 06 '25 18:12

WannaCSharp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!