0

I have a model

public class DeModel
{
  public string id{get;set;}
  public string Name{get;set;}
  public List<AdressesModel>{get;set;}
}

public class AdressesModel
{
 public string id{get;set;}
 public string line1{get;set;}
 public string line2{get;set;}
 public string hometown{get;set;}
 public string city{get;set;}
 public string country{get;set;}
}

In my view, user should be able to add or delete addresses and I should be able to get the final list on the post back.

Js is one way , but it is too complicated , I have to keep track of the indexes and I need to change alot when the model changes.

I see that editorfortemplates with ajax call is an option but couldn't figure out how to do that .

How can I do this other than JS ?

Burak Gazi
  • 535
  • 2
  • 7
  • 23
  • You will need javascipt/jquery one way or the other. You can look at the [BeginCollectionItem](https://www.nuget.org/packages/BeginCollectionItem/) helper. Refer [this tutorial](http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/) for an example –  Aug 10 '15 at 08:49
  • And for a pure client side solution, refer [this answer](http://stackoverflow.com/questions/28019793/submit-same-partial-view-called-multiple-times-data-to-controller/28081308#28081308) –  Aug 10 '15 at 08:50
  • You can do that using KnockoutJS – Sirwan Afifi Aug 10 '15 at 09:25

0 Answers0