c# - add items in list from view -


i have model class

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);     }     ... } 

and in view have:

@model solution.models.cv ... @html.textboxfor(m => m.neweducation.faculty) ... 

and desired textboxes education class. want add these items in list after click add button:

<div class="add-education">  <a href="" class="add-education-button">add education</a> </div> 

how can that?

in cv class there lists too. want way (from 1 model)

try post controller's action html input:

<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> 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -