Моя модель просмотра:
public class CompanyAccountViewModel
{
public string Name { get; set; }
public float Interval { get; set; }
public List<string> MobileNo { get; set; }
}
и Моя точка зрения:
@model PowerSupply.Models.CompanyAccountViewModel
@{
ViewBag.Title = "Register";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h3>Register</h3> <br />
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group row">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "col-sm-2 col-md-1 col-form-label" })
<div class="col-sm-10 col-md-3">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group row">
@Html.LabelFor(model => model.Interval, htmlAttributes: new { @class = "col-sm-2 col-md-1 col-form-label" })
<div class="col-sm-10 col-md-3 positioned_relative">
@Html.EditorFor(model => model.Interval, new { htmlAttributes = new { @class = "form-control" } })
<span class="help-text">Hour</span>
@Html.ValidationMessageFor(model => model.Interval, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group row">
@Html.LabelFor(model => model.MobileNo, htmlAttributes: new { @class = "col-sm-2 col-md-1 col-form-label" })
<div class="col-sm-10 col-md-3">
<span class="add-new-icon glyphicon glyphicon-plus-sign" id="add_mobile"> </span>
@Html.EditorFor(model => model.MobileNo, new { htmlAttributes = new { @class = "form-control",@id= "add_mobile" } })
@Html.ValidationMessageFor(model => model.MobileNo, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group row new_mobile_wrapper">
<div class="col-md-offset-3">
<div class="new_mobile_container">
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-offset-2 col-sm-10 col-md-2">
<input type="submit" value="Register" class="btn btn-primary col-sm-offset-1" />
</div>
</div>
}
Здесь я все поле отображается правильно, но:
@Html.EditorFor(model => model.MobileNo, new { htmlAttributes = new { @class = "form-control",@id= "add_mobile" } })
Это не создает никакой разметки.Я указываю причину, и это связано с типом сущности.Тип сущности MobileNo - Список.Как изменить это @Html.EditorFor
?Любая идея?Это убивает весь мой день.