如何将 ASP.NET MVC Html.ActionLink 的标题属性设置为生成的 URL
我希望用户将鼠标悬停在链接上时能够看到 Html.ActionLink() 生成的锚标记的相应 URL。这是通过设置 title 属性来完成的,但我陷入困境的是弄清楚如何获取该值:
@Html.ActionLink(@testrun.Name, "Download", "Trx",
new { path = @testrun.TrxPath }, new { title = ??)
How can I指定 ActionLink 将生成的 URL?我可以对我猜的东西进行硬编码,但这违反了DRY。
I would like users to be able to see the corresponding URL for an anchor tag generated by Html.ActionLink() when they hover over the link. This is done by setting the title attribute but where I'm stuck is figuring out how to get that value:
@Html.ActionLink(@testrun.Name, "Download", "Trx",
new { path = @testrun.TrxPath }, new { title = ??)
How can I specify the URL that ActionLink is going to generate? I could hardcode something I guess but that violates DRY.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Url.Action() 生成链接,也可以创建如下所示的自定义帮助器方法:
现在基本上您只需要像这样调用新的 ActionLinkHelper
You could use Url.Action() to generate the Link or you could Create a Custom Helper Method like this:
Now basically you will simply need to call your new ActionLinkHelper like this
jQuery 是可以解决的。
It is possible to solve jQuery.
Url.Action() 方法应该可以
,但我不确定是否有更好的方法。
The Url.Action() method should work
But I'm not sure if there's a better way.