Pager_Link ?

Topics: Writing themes
Apr 10, 2013 at 9:10 PM
Edited Apr 10, 2013 at 9:53 PM
I alternate Pager_Link:
@{
var RouteValues = (object)Model.RouteValues;
RouteValueDictionary rvd;
if (RouteValues == null) {
            rvd = new RouteValueDictionary();
        }
        else {
            rvd = RouteValues is RouteValueDictionary ? (RouteValueDictionary)RouteValues : new RouteValueDictionary(RouteValues);
        }

string title = Html.Encode(Model.Value is string ? (string)Model.Value : Display(Model.Value));
}

@Html.ActionLink(linkText: @title, actionName:(string)rvd["action"], controllerName:(string)rvd["controller"], routeValues:rvd, htmlAttributes: null)

I is OK, but if I use :

@Html.ActionLink(linkText: @title, actionName:(string)rvd["action"], controllerName:(string)rvd["controller"], routeValues:rvd, htmlAttributes: new { @class= "art-button"} )

it is not working.
Why?
Developer
Apr 10, 2013 at 10:01 PM
Could you elaborate on what you are seeing as a result that is unexpected? Please provide the relevant HTML output.
Apr 11, 2013 at 10:47 AM
Edited Apr 11, 2013 at 10:57 AM
sfmskywalker wrote:
Could you elaborate on what you are seeing as a result that is unexpected? Please provide the relevant HTML output.
Hi, Sipke

if I use "null" I get right link :

<a href="/forum-01/how-to-fuck-over-intel-processors?page=2" shape-id="113">2</a>

in case of " new { @class= "art-button"} " I get some kinda abracadebra :

<a class="art-button" href="/Forums/Thread/Item?Count=6&Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D" shape-id="113">2</a>

The case is in NGM forum's post pager

It is very weird, because I use named parameters.

by the way, I alternate (use in mytheme) Pager.schtml as well from admin theme...

just removed shape tracing, problem persists :(

set: W8Pro, VS2012, DevServer, Orchard1.6, compactDB

mvc bug ?


--negocifal-sonyka.
Developer
Apr 11, 2013 at 11:30 AM
Looks like it. Did you try using positional arguments instead of named arguments?
Apr 11, 2013 at 11:49 AM
sfmskywalker wrote:
Looks like it. Did you try using positional arguments instead of named arguments?
Yes, the same with :

Html.ActionLink(@title, (string)rvd["action"], (string)rvd["controller"], rvd, null)


for clear
aliase:
forum-01/how-to-fuck-over-intel-processors

route:
Forums/Thread/Item?forumId=129&threadId=218
Apr 11, 2013 at 3:08 PM
workaround:

@Html.ActionLink(@title, (string)rvd["action"], (string)rvd["controller"],
  rvd,
  new Dictionary<string, object> { { "class", "art-button" } });

source :
http://stackoverflow.com/questions/4108943/actionlink-htmlattributes