Solved

html.actionlink htmlattributes dictionary bug?

Posted on 2011-09-12
4
597 Views
Last Modified: 2013-11-05
I am trying to use the Html.Actionlink overload that takes and IDictionary<String, Object> as the htmlAttributes parameter.To simplify it, look at this example:

@Html.ActionLink("TEST", "Test", new { test = 1 }, new Dictionary<string, object>())

That is outputting the following HTML:

<a Comparer="System.Collections.Generic.GenericEqualityComparer`1[System.String]" Count="0" Keys="System.Collections.Generic.Dictionary`2+KeyCollection[System.String,System.Object]" Values="System.Collections.Generic.Dictionary`2+ValueCollection[System.String,System.Object]" href="/Controller/Test?test=1">TEST</a>

i.e. it is writing out all the internal properies of the Dictionary object rather than that acual key value pairs within it.

Obviously, I have tried it with actual data in the dictionary too and the same thing happens.

Am i doing something silly, or is that a bug?

Thanks
0
Comment
Question by:ShaunMitchem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:ShaunMitchem
ID: 36521846
Thanks, but that relates to the Route Value parameter - my query is about that htmlAttributes which is an IDictionary<String, Object> according to the help file (and Intellisense)
0
 

Accepted Solution

by:
ShaunMitchem earned 0 total points
ID: 36528364
SOmeone on forums.asp.net helped me with this.  

If instead of using an anonymous type for the RouteValueDictionary as i was doing previously and instead use the explicit declaration:

new RouteValueDictionary(new { id = 1 })

then the problem with the HtmlAttributes dictionary goes away.

I guess this must be because the:

ActionLink(HtmlHelper, String, String, Object, Object)

overload was being used and it therefore wasnt seeing the dictionary as a dictionary - i.e. was iterating through the standard object properties instead
0
 

Author Closing Comment

by:ShaunMitchem
ID: 36555743
This is the answer
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question