javascript - MVC post list of objects with property of SortedDictionary type -
javascript - MVC post list of objects with property of SortedDictionary type -
im working on mvc project , im stuck posting unknown number of values (complex object) - input fields javascript generated. problem on form post, properties of type sorteddictionary empty.
here how of looks like: controller:
public virtual actionresult addlocation(companylocationmodel model) { ...do model ... }
the companylocationmodel(simplified):
public class companylocationmodel { public companylocationmodel() { workinghours = new list<workinghour>(); } public objectid id { get; set; } public list<workinghour> workinghours { get; set; } ..... }
the working hr class:
public class workinghour { public workinghour() { hours = new sorteddictionary<datetime, datetime>(); } public int dayofweek { get; set; } public sorteddictionary<datetime, datetime> hours { get; set; } }
how html should like? i've tried this:
<input type="hidden" name="workinghours[0].dayofweek" value="1"> <input type="hidden" name="workinghours[0].hours[08:00]" value="16:00"> ... repeat n times...
and this:
<input type="hidden" name="workinghours[0].dayofweek" value="2"> <input type="hidden" name="workinghours[0].hours.key" value="08:00"> <input type="hidden" name="workinghours[0].hours.value" value="16:00"> ... repeat n times...
but doesnt work. workinghours list submited , dayofweek value of each item on post, hours value empty.
javascript c# asp.net-mvc post sorteddictionary
Comments
Post a Comment