I have a javascript array that is being passed back to the controller
amount_array[]
and it contains different named keys such as
amount_array['start_date'] , amount_array['end_date']
with more variables like that in the array
Is there any way to set a array up in C# on the controller to call the start and end date from the array by name?
Or will I just have to call by the position in the array?
Any help is appreciated.
Thanks
No, you don’t have a javascript array. In javascript arrays must have integer 0 based indexes. What you have is a javascript object with 2 properties:
start_dateandend_date.So you define a view model to match this structure:
then a controller action to take this view model and do some processing with it:
and finally a javascript function to invoke this controller action (using AJAX for example):