I want to pass a nested Dictionary into the EditorFor viewData.
@{
var viewData = new RouteValueDictionary();
var htmlAttributes = new RouteValueDictionary();
htmlAttributes.Add("title", "foo");
viewData["htmlAttributes"] = htmlAttributes;
}
Html.EditorFor(model => model.SomeProperty, viewData);
The problem is that the tile="foo" does not get rendered. When I'm using
var htmlAttributes = new {title = "foo"};
everything is working as expected.
I need htmlAttributes to be a Dictionary, because in my application it is dynamically generated.
So how can I pass a Dictionary in there. I already tried to pass in thmlAttributes as an ExpandoObject, but that does not work either.
It is currently not possible (MVC 5.2) see this Bug: https://aspnetwebstack.codeplex.com/workitem/1736