How to dynamically add to list with ViewModel in ASP.NET Core 3.1 MVC with JavaScript and C#
- 阅读更多 关于 How to dynamically add to list with ViewModel in ASP.NET Core 3.1 MVC with JavaScript and C#
问题 I am trying to dynamically add to a list property in my ViewModel using JavaScript. Whenever I submit my form, there are no items in the list in the post controller. I have tried to add to the list inside the JavaScript function using razor syntax like so: @{ Model.Contacts.Add(new Contact { ID = 1, FirstName = "Tester" }) } Just to see if I could even get a item in the list. I've also done it at the top of the page to see if it was just because it was in JavaScript. However when I submitted