c# - adding css and id selector to input box (razor helper) -


inside razor view have textbox rendered razor helper

@html.editorfor(model => model.caption,         new { htmlattributes = new { @class = "form-control" } }) 

i want add css id class form-control class tried

@html.editorfor(model => model.caption,          new { htmlattributes = new { @class = "form-control", @id="myid" } }) 

but doesnt work.

by default have id, caption.

if want change it, acccording this answer have change editorfor textboxfor. this, need remove new { htmlattributes because textboxfor expects htmlattributes , editorfor expects additionviewdata.

@html.textboxfor(model => model.caption, new { @class = "form-control", @id="myid" } ) 

i want mention code, is, changed id when tested.

@html.editorfor(model => model.caption,      new { htmlattributes = new { @class = "form-control", @id="myid" } }) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -