我如何在@ url.action中使用#

编程入门 行业动态 更新时间:2024-10-24 14:27:44
本文介绍了我如何在@ url.action中使用#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将我的HTML模板继承到mvc 但我找不到将这个html代码转换为MVC的方法 < a href =abc.html#abc> 我尝试过: i已经尝试了

I want to inherit my HTML template into mvc but I couldn't find a way to convert this html code to MVC <a href="abc.html#abc> What I have tried: i have tried

<li>@html.actionlink("abc","abc@abc","abc")</li>

推荐答案

我假设当你说abc.html时你指的是MVC frameowrk中控制器中的动作。如果你想直接引用.html,你就不会在那种情况下使用Html.ActionLink。 假设你有Index.cshtml和About.cshtml在HomeController中。 要在index.cshtml的URL中引用id为testdiv的div(在你的例子abc.cshtml中,id为abc)你会执行以下操作 I'm assuming when you say abc.html you're referring to the action in a controller within the MVC frameowrk. If you want to reference the .html directly you're not really using Html.ActionLink in that situation. Lets say you have Index.cshtml and About.cshtml both within the HomeController. To reference div with id of "testdiv" in a URL from index.cshtml (in your example abc.cshtml with id of abc) you would do the following <a href="@Url.Action("About", "Home")#testdiv">Click me</a>

这会产生一个点击我链接,其href值为/ home / about#testdiv。 所以你需要做

Which would generate a link of "Click Me" with a href value of /home/about#testdiv. So you would need to do

<a href="@Url.Action("abc", "YourControllerName")#abc">Clcik me</a>

更多推荐

我如何在@ url.action中使用#

本文发布于:2023-11-03 20:35:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1556025.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   url   action

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!