vb.net 如何重定向到我的 aspx 页面上的锚标记

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20482395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 16:05:15  来源:igfitidea点击:

How do I redirect to an anchor tag on my aspx page

asp.netvb.netanchor

提问by Oumie

I tried Response.Redirect("page.aspx#here")but it did not work.

我试过了,Response.Redirect("page.aspx#here")但没有用。

This is the code in my aspx file: <a name="here"></a>Do I have to redirect to it differently?

这是我的 aspx 文件中的代码:<a name="here"></a>我必须以不同的方式重定向到它吗?

采纳答案by timbck2

You can't redirect to an anchor from server-side code, because the anchor is entirely a client-side concept. You'll have to use Javascript for this. See Retrieving Anchor Link In URL for ASP.Net.

您不能从服务器端代码重定向到锚点,因为锚点完全是客户端的概念。为此,您必须使用 Javascript。请参阅在 ASP.Net 的 URL 中检索锚链接

回答by San

The accepted answer here is incorrect.

这里接受的答案是不正确的。

I am able to make this work in C# by doing the following:

我可以通过执行以下操作在 C# 中完成这项工作:

Response.Redirect("page.aspx" + "#here", false);