Michael
Michael

Reputation: 13614

How to set style when BeginForm html helper is created?

I use in my mvc5 project Html.BeginForm() html helper.

I need to create the element and set style = "pedding:12px!important"

I saw many examples in the web but the are all uses class, I dont want to declare class I just need to put style as is.

How can I implement it?

Upvotes: 1

Views: 174

Answers (1)

Moeri
Moeri

Reputation: 9294

You need this overload.

Html.BeginForm("MyAction", "MyController", FormMethod.Post, new { style = "padding:12px" })

Not sure why you would add !important to the CSS if the rule is defined on the element itself. Doesn't that override any CSS anyway?

The use of !important should be reserved for overriding other "!important" rules from libraries you cannot modify.

Upvotes: 1

Related Questions