我有那个模特课
public class CV
{
...
public List<Education> education { get; set; }
public Education newEducation { get; set; }
public void addEducation(CV cv)
{
cv.education = cv.education ?? new List<Education>();
cv.education.Add(cv.newEducation);
}
...
}
并且我认为:
@model solution.Models.CV
...
@Html.TextBoxFor(m => m.newEducation.Faculty)
...
和该教育类的所需文本框。现在我想在点击添加按钮后在列表中添加这些项目:
<div class="add-education">
<a href="" class="add-education-button">add education</a>
</div>
我该怎么做?
在我的CV
课程中,还有另一个列表。所以我想通过这种方式(从一个模型)来做到这一点
答案 0 :(得分:1)
尝试从html输入发布到Controller的操作:
<form method="post" action="yourNameController/nameAction">
<div>
@model solution.Models.CV
...
@Html.TextBoxFor(m => m.newEducation.Faculty)
</div>
<div class="add-education">
<button type="submit" class="add-education-button">add education</button>
</div>
</form>