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

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -