删除回发时的锚点
与此问题相反: Retainanchor after postback in asp.net
我我遇到的问题是,在回发时,它保持锚定。
我从 Browse.aspx 开始;用户单击某些内容,将他们带到页面上的锚点。然后,他们从 DropDownList 中选择一个新的过滤器,因此它会刷新到过滤器就位的第 1 页,但锚点仍保留在 url 中,导致他们向下跳转页面。
我尝试将 PostBackUrl="~/Browse.aspx" 属性添加到 DropDownList 但无济于事。
有什么想法吗?
请注意,我将使用后面代码中的以下方法将它们发送到锚点:
RegisterStartupScript("navigateto", "<script type='text/javascript'>document.location.href='#photo1';</script>");
Opposite of this question: Retain anchor after postback in asp.net
I'm having the issue that on postback, it's keeping an anchor.
I'm starting in Browse.aspx; user clicks something which takes them to an anchor on the page. They then choose a new filter from DropDownList, so it refreshes back to page 1 with the filter in place, but the anchor stays in the url causing them to jump down the page.
I tried added PostBackUrl="~/Browse.aspx" attribute to the DropDownList to no avail.
Any ideas?
Note, I'm sending them to the anchor with he following method in code behind:
RegisterStartupScript("navigateto", "<script type='text/javascript'>document.location.href='#photo1';</script>");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为当用户选择新的过滤器时,您必须执行 server.redirect (或注入另一个刷新页面的客户端脚本),而网址中没有锚点。浏览器本身不会在回发期间丢失它。
I think you'll have to do a server.redirect (or inject another client script that refreshes the page) when the user chooses a new filter, without the anchor in the url. The browser on its own will not lose it during post-backs.