Вопрос

SO community

I have the following issue:

If i render an ActionLink like this:

@Html.ActionLink(titleText, 
    Title.Href.TargetAction, 
    Title.Href.TargetController, 
    Title.Href.TargetRouteValues, 
    null)

the rendered element is:

<a href="/eagle/Intervention/Edit_Inv?ID_INV=53165">        19/      2013</a>

but if i add an object as HTMLAttributes like this:

@Html.ActionLink(titleText, 
    Title.Href.TargetAction, 
    Title.Href.TargetController, 
    Title.Href.TargetRouteValues, 
    new {target="_blank"})

i get the following markup:

<a href="/eagle/Intervention/Edit_Inv?Count=1&amp;Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&amp;Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D" target="_blank">        19/      2013</a>

What are my options here?

Thanks in advance, Silviu.

Это было полезно?

Решение

Well, this was quick! I cracked it:

@Html.ActionLink(titleText, 
      Title.Href.TargetAction, 
      Title.Href.TargetController,
      Title.Href.TargetRouteValues, 
      new Dictionary<string, object> { { "target", "_blank" } })

This got me out. Instead of providing an anonymous object for the HTMLAttributes, i used an IDictionary, and it now works like a charm.

Thanks for the interest, however, Nick, your solution is not valid ;)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top