ASP.NET Core MVC add / remove dynamic content
I am currently developing a system that manages and analyzes uptime. So I need to add multiple timestamps once and add / remove some input field dynamically.
The ViewModel looks like this:
public class CreateWorkDayViewModel
{
public DateTime Date { get; set; }
public IEnumerable<CreateStampModel> Stamps { get; set; }
}
public class CreateStampModel
{
public string ProjectId { get; set; }
public DateTime From { get; set; }
public DateTime To { get; set; }
}
How do I do this with razer syntax including validation?
I am working with Visual Studio version 15.2 and the latest stable MVC.
EDIT (05/17/17):
What I have done so far:
I added a jQuery based mechanism to add / remove rows dynamically.
Click for mechanism
My problem is that in the part where I add lines (in JS line 4) I can't use razor syntax because this html code is inserted at runtime jQuery.
I also tried it the old way and used instead asp-for
name
. This works for post data, but in order to populate the project dropdown I need data from the ViewModel and this is missing.
source to share
No one has answered this question yet
See similar questions:
or similar: