Solved

html.actionlink htmlattributes dictionary bug?

Posted on 2011-09-12
4
607 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

636 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