我有两个模型类
public partial class EndUser
{
public EndUser()
{
this.Mobiles = new List<Mobile>();
}
public virtual long Id { get; set; }
public virtual string FullName { get; set; }
[DataType(DataType.Password)]
public virtual string UserPassword { get; set; }
public virtual string Email { get; set; }
public virtual IList<Mobile> Mobiles { get; set; }
public partial class Mobile
{
public virtual long Id { get; set; }
public virtual string Number { get; set; }
public virtual EndUser EndUser { get; set; }
}
我的控制器
public ActionResult CreateClient()
{
return View("CreateClient");
}
脚手架模板创建我的视图
创建客户端
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>EndUser</legend>
<div class="editor-label">
@Html.LabelFor(model => model.FullName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.FullName)
@Html.ValidationMessageFor(model => model.FullName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.UserPassword)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.UserPassword)
@Html.ValidationMessageFor(model => model.UserPassword)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Email)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
但我想从这个视图添加我的客户端手机。如何创建乘法(未知)文本字段来添加手机号码?如果客户有多个手机号码,他可以通过单击“添加更多号码”按钮添加更多文本框。我无法为手机号码字段创建文本框。
请帮帮我。我是 MVC 的新手。