vendredi 10 avril 2015

How to put javascript array into MVC Model View array ?

In one view i create an array in javascript that contains ids of elements and now i want to pass them into model field in my MVC Model does anybody already meet ith this kind of problem this is my model:



public class AppointmentModel
{
public int Id { get; set; }
public string Title { get; set; }
public int[] PersonsIds { get; set; }
public int[] CompaniesIds { get; set; }
}


and in view i keep both arrays as hidden fields



@html.hiddenfor(model => model.PersonsIds)
@html.hiddenfor(model => model.CompaniesIds)


so the schema looks like this:



javascript->model->submit model->controller


Please any help would be appreciate





Aucun commentaire:

Enregistrer un commentaire