c# - How do I get Html.RouteLink() to work with a RouteValueDictionary while passing Html Attributes? -
hey there so... here's riddle:
<%: html.routelink("asd",item.routevalues) %> <%: html.routelink("asd",item.routevalues, new{title="title"}) %>
the first line correctly spits out code:
<a href="/">asd</a>
the second line incorrectly spits out code:
<a href="/?count=4&keys=system.collections.generic.dictionary%602%2bkeycollection%5bsystem.string%2csystem.object%5d&values=system.collections.generic.dictionary%602%2bvaluecollection%5bsystem.string%2csystem.object%5d" title="title">asd</a>
i expecting code this:
<a href="/" title="title">asd</a>
so tried bit more explicit in view writing way:
<%: html.routelink("asd",(routevaluedictionary)item.routevalues, new{title="title"}) %>
but had same (incorrect) result.
any thoughts?
the problem there no overload html.routelink(string, routevaluedictionary, object)
so needed pass html attriute dictionary this:
<%: html.routelink( "link", item.routevalues, new dictionary<string,object>{{"title", "title text"}}) %>
kind of messy... works.
Comments
Post a Comment