2

I have a visualization problem with a simple button, this renders perfectly

@Html.ActionLink("<", "Monthly", "Agenda", null, new Dictionary<string, object> { { "data-role", "button" }, { "data-theme", "c" }, { "data-mini", "true" } })

the action I'm calling though need parameters, therefore I changed it in

@Html.ActionLink("<", "Monthly", "Agenda", new { shift = -1 }, new Dictionary<string, object> { { "data-role", "button" }, { "data-theme", "c" }, { "data-mini", "true" } })

following this answer HTML.ActionLink method

When I change it as above the button does it's jobs but it doesn't render as a jquery mobile button anymore

it goes from this http://i47.tinypic.com/alhs9h.png

to this http://i48.tinypic.com/351ft5z.png

Thank you for helping me out

Community
  • 1
  • 1
gigasean
  • 115
  • 1
  • 10

1 Answers1

5

To hit the correct Html.ActionLink overload you need to pass the RouteValues as a RouteValueDictionary (not an anonymous object):

@Html.ActionLink("<", "Monthly", "Agenda", 
                 new RouteValueDictionary() { { "shift", -1 } }, 
                 new Dictionary<string, object> { { "data-role", "button" }, { "data-theme", "c" }, { "data-mini", "true" } })

Alternatively, shorter / easier to read, you can pass both the RouteValues and the HtmlAttributes as anonymous objects:

@Html.ActionLink("<", "Monthly", "Agenda", new { shift = -1 }, new { data_role = "button", data_theme = "c", data_mini = "true" })

In the anonymous object version you have to use data_ instead of data-, but the helper substitutes _ with - before displaying the attribute keys so the output is the same.

pjumble
  • 16,880
  • 6
  • 43
  • 51