My viewmodel -
public class HashedArrayViewModel
{
[Required]
[Display(Name = Constants.HashNameLabel)]
public string HashName { get; set; }
[Required]
[Display(Name = Constants.HashColumnLabel)]
public string HashColumn { get; set; }
[Required]
[Display(Name = Constants.HashAlgorithm)]
public string HashAlgorithm { get; set; }
}
in another view-model, I am referencing above class-
[Required]
[Display(Name = Constants.HashArrayLabel)]
public HashedArrayViewModel HashColumns { get; set; }
My view-
<div>
@Html.EditorFor(model => model.HashColumns, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.HashColumns, "", new { @class = "" })
</div>
Generate markup -
<div class="" id="hashcolumn" style="">
<div>
<div class="editor-label"><label for="HashColumns_HashName">Hash Name</label></div>
<div class="editor-field"><input class="form-control text-box single-line" data-val="true" data-val-required="The Hash Name field is required." id="HashColumns_HashName" name="HashColumns.HashName" type="text" value=""> <span class="field-validation-valid" data-valmsg-for="HashColumns.HashName" data-valmsg-replace="true"></span></div>
<div class="editor-label"><label for="HashColumns_HashColumn">Hash Columns</label></div>
<div class="editor-field"><input class="form-control text-box single-line" data-val="true" data-val-required="The Hash Columns field is required." id="HashColumns_HashColumn" name="HashColumns.HashColumn" type="text" value=""> <span class="field-validation-valid" data-valmsg-for="HashColumns.HashColumn" data-valmsg-replace="true"></span></div>
<div class="editor-label"><label for="HashColumns_HashAlgorithm">Hash Algorithm</label></div>
<div class="editor-field"><input class="form-control text-box single-line" data-val="true" data-val-required="The Hash Algorithm field is required." id="HashColumns_HashAlgorithm" name="HashColumns.HashAlgorithm" type="text" value=""> <span class="field-validation-valid" data-valmsg-for="HashColumns.HashAlgorithm" data-valmsg-replace="true"></span></div>
<span class="field-validation-valid " data-valmsg-for="HashColumns" data-valmsg-replace="true"></span>
</div>
</div>
and if you notice in the above image, labels and fields are on the top of each other
my question is -
how do I change the css classes on labels and fields. By default razor adds editor-label
and editor-field
respectively. I want to use col-md-10
and col-md-10
.
Any other suggestion to fix the alignment is highly welcome.