I have a partial view which is being called (async) from jquery. I loop through some data and builds a dictionary I delare at the top of the partial view (so one dictionary per call to the partial view).
Dictionary<string, string> vals = new Dictionary<string, string>();
Each time round the loop i'm adding an item to the 'vals' dictionary:
tftr_si
Member
713 Points
220 Posts
Passing a Dictionary<string, string> to a controller
Jun 02, 2011 01:39 PM|LINK
Hi guys and gals,
I have a partial view which is being called (async) from jquery. I loop through some data and builds a dictionary I delare at the top of the partial view (so one dictionary per call to the partial view).
Each time round the loop i'm adding an item to the 'vals' dictionary:
Then outside the loop, I call my action passing the dictionary:
@Html.Action("MyActionName", new { vals = @vals })The only problem is on the action, I get a blank dictionary come through?!
Anyone know why!? I'm stumped.
tftr_si
Member
713 Points
220 Posts
Re: Passing a Dictionary<string, string> to a controller
Jun 02, 2011 03:35 PM|LINK
Hi all,
Ok, I realised what my prob was. I now call the action which returns an image (as a FileContentResult) to sit in an image tag.
<img alt="" src="@{Html.RenderAction("MyActionName", vals);}" />The only problem is I'm doing this via a JQuery ajax call so there are many requests to it.
Each time i run the page, I get the Exception:
with the inner exception:
francesco ab...
All-Star
20944 Points
3286 Posts
Re: Passing a Dictionary<string, string> to a controller
Jun 02, 2011 09:11 PM|LINK
Renderaction accept a RouteValueDisctionary not a Dictionary<...>
Mvc Controls Toolkit | Data Moving Plug-in Videos