Html.Action 链接和 Html.RouteLink
即使 url 相同,我也可以使用 Html.RouteLink 和 Action Link 转到不同的操作。就像当我单击新闻链接时,我将转到新闻详细信息。此页面的 url 是 http://localhost:1390/en-US/latestnews/125.Now 如果我在中选择语言的 ddl此页面中的站点标题我需要 转到站点的主页。ddl(更改时)将采用相同的 url,但这次需要转到理智控制器中的操作。
Even If the url is same can i go to different action using Html.RouteLink and Action Link.Like when i click on news link i will go to news details.The url of this page is http://localhost:1390/en-US/latestnews/125.Now if i select the ddl of language in the site header in this pagei need to
go to the home page of the site.The ddl (on change) will take the same url but this time it needs to go to action in the sane controller.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论您如何生成它,该 URL 将定向到它匹配的第一个路由条目上的控制器/操作。我不确定你到底想要完成什么,但我怀疑你需要做的是使用 javascript 定向到不同 url,可能是用
Html.RouteLink
生成的code> 而不是Html.ActionLink
基于选择下拉列表时的值。如果我误解了您想要做什么,请澄清。The URL will direct to the controller/action on the first routing entry that it matches regardless of how you generate it. I'm not sure exactly what you are trying to accomplish, but I suspect that what you need to do is use javascript to direct to a different url, perhaps generated with
Html.RouteLink
instead ofHtml.ActionLink
based on the value of the drop down list when it's selected. If I'm misunderstanding what you are trying to do, please clarify.