ASP.NET MVC ActionLink的渲染错误 [英] ASP.NET MVC ActionLink renders erroneously
本文介绍了ASP.NET MVC ActionLink的渲染错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SO社区
我有以下问题:
如果我渲染ActionLink的是这样的:
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>
但如果我添加一个对象作为HTMLAttributes是这样的:
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&Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&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" } })
这让我出去。相反,对于HTMLAttributes提供一个匿名对象,我用一个IDictionary,它现在就像一个魅力。
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 ;)
这篇关于ASP.NET MVC ActionLink的渲染错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文