twitter bootstrap 3 - MVC5 and Bootstrap3: Html.EditorFor wrong class? How to change? -


i noticed mvc 5 using different class input fields when using editorfor. think lower version of bootstrap, current class doesn't add up.

i'm talking this:

<div class="form-group">     @html.labelfor(model => model.contact.cellphoneno, new { @class = "control-label col-md-4"})        <div class="col-md-8">            @html.editorfor(model => model.contact.cellphoneno)            @html.validationmessagefor(model => model.contact.cellphoneno)        </div> </div> 

which results this:

<div class="form-group">     <label class="control-label col-md-4" for="contact_cellphoneno">cellphoneno</label>     <div class="col-md-8">         <input class="text-box single-line" id="contact_cellphoneno" name="contact.cellphoneno" type="text" value="">         <span class="field-validation-valid" data-valmsg-for="contact.cellphoneno" data-valmsg-replace="true"></span>     </div> </div> 

when @ tag, has "text-box" class instead of bootstrap3's "form-control"

i think read around somewhere due fact of mvc5 switching bootstrap 3 @ last minute or something.


question is: how change class manually? want able change text-box form-control. can't find code though.

i've tried already

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

which doesn't seem work. i'm stumped. ideas?

thanks in advance!

editorfor doesn't accept html attributes parameter. parameter using additionalviewdata

use textboxfor instead

@html.textboxfor(m => m.username, new { @class = "form-control" }) 

edit

as of mvc 5.1, html attributes can passed editortemplate using syntax

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

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -