使用@ Url.Action在mvc中传递节ID,以便在重定向后将用户滚动到特定节 [英] passing section id in mvc using @Url.Action so that user will be scrolled to a particular section after redirecting

查看:56
本文介绍了使用@ Url.Action在mvc中传递节ID,以便在重定向后将用户滚动到特定节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名网页设计师,但被告知要在mvc中设计静态页面,而不是使用href ="some url",而我必须使用href ="@ Url.Action(" Controller,View)"现在在URL中传递一个部分ID,因此当用户重定向时,通常会在html中将其向下滚动到该特定部分,这是我使用的语法

I am a web designer but I am told to design static pages in mvc where rather then using href="some url" I have to use href="@Url.Action("Controller", View)" Now I want to pass a section id in the url so when the user redirects it will be scrolled down to that specific section usually in html this is the syntax I use

href="index.html#mysectionid"

在HTML中,我有类似的东西

in Html I have something Like this

<section id="mysection">

</section>

我想知道我将如何在mvc中执行此操作.谢谢

I want to Know How I am gonna do this thing in mvc. Thanks

推荐答案

您可以在Razor中将C#代码与普通html混合使用:

You can mix C# code with normal html in Razor:

<a href="@Url.Action("Contact", "Home")#mysection">Test</a>

这篇关于使用@ Url.Action在mvc中传递节ID,以便在重定向后将用户滚动到特定节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆