嘿SO ...這裏是一個謎:如何在傳遞Html屬性時使Html.RouteLink()與RouteValueDictionary一起使用?
<%: Html.RouteLink("asd",item.RouteValues) %>
<%: Html.RouteLink("asd",item.RouteValues, new{title="title"}) %>
第一行正確地吐出了這樣的代碼:
<a href="/">asd</a>
第二行不正確地吐出了這樣的代碼:
<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>
我期待的代碼如下所示:
<a href="/" title="title">asd</a>
於是,我就在視圖更明確一點寫這樣說:
<%: Html.RouteLink("asd",(RouteValueDictionary)item.RouteValues, new{title="title"}) %>
但我有同樣的(不正確)的結果。
有什麼想法?
當我看重載時,我意識到`object routValues`和`RouteValueDictionary`之間有區別 – quakkels 2011-02-17 18:06:57