The Scenario is where :-
Controller part :
public ActionResult GoHt()
{
Dictionary<string, string> col = new Dictionary<string, string>();
col.Add("A", "C");
col.Add("B", "C");
ViewBag.Cols = col;
return View();
}
View Part :
<input type="hidden" id="HD" name ="HD" value="@ViewBag.Cols" />
In this case hidden value is not showing Dictionary element which id defined instead it is show as
<input type="hidden" id="HD" name="HD" value="System.Collections.Generic.Dictionary`2[System.String,System.String]">
Here the Question is , how do i assign Dictionary element to ViewBag and store in Hidden field.
and how do the same Dictionary is made available at Form Submission.
Controller :
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GoHt(FormCollection formCollection)
{
var Mode = (Dictionary<string, string>)formCollection["HD"].ToString();
}