单击按钮时如何将一组字段重复添加到我的页面?我的 ParentView.cshtml 上有一个“添加记录”按钮
单击此“添加记录”按钮,我需要将下面提到的剃须刀视图(childView.cshtml)附加到我的 ParentView 上。每次单击此“添加记录”按钮时,我都需要新的空 ChildView.cshtml附加到我的父视图中。有人可以帮助我如何实现此功能吗?
ChildView.cshtml
<p>Record index
@Html.EditorFor(model => model.Name)
@Html.EditorFor(model => model.Address)
@Html.EditorFor(model => model.Location)
<input type="submit" id="btnSave" value="Save" />
我的 ParentView.cshtml 如下所示
@model MyWebRole.ViewModels.MyViewModel
@{
ViewBag.Title = "Address Book";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
<fieldset>
<legend style="font-size: small;">Add Address records </legend>
<br />
<table>
<tr>
<td rowspan="5">
<img alt="" id="imageBox" src="" width="395" height="225" />
</td>
<td>
<span>Address Book </span>
<br />
</td>
<td>
@Html.EditorFor(model => model.REcordTitle)
@Html.ValidationMessageFor(model => model.REcordTitle)
</td>
</tr>
------------------------
------------------------
</table>
<div><input type="submit" id="btnAdd records" value="Add Records" /></div>
</fieldset>
}