How to add another attributes to Html.Editorfor, not just only class

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to add another attributes to Html.Editorfor, not just only class


@Html.EditorFor(model => model, new htmlAttributes = new @class = "form control" , )



This works, but when i try to add another attribute to htmlAttributes, it gives an error.




2 Answers
2



You are putting the next attribute outside of the htmlAttributes object by the looks of it. Instead, you want this:


htmlAttributes


@Html.EditorFor(model => model, new htmlAttributes = new @class = "form control", style = "background: blue" )



You need to do something like following:


@Html.EditorFor(model => model, htmlAttributes: new @class = "form control",
id="id"

})






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard