从回发返回时加载 URI 中包含目标的页面
我在网页上有多个段,用目标标识,如下所示:
<div id="target1" class="section">
<h4><a href="#target1">Buildings by Name</a></h4>
<div>
// button to call server side function
</div>
</div>
因此,当用户单击“按名称排列的建筑物”时,URI 更改为 http://www.mydomain.com/page.aspx#target1
我需要打电话服务器端函数,它将进行一些处理。当我从服务器端脚本返回时,我想使用相同的目标 URI 重新加载页面 http://www.mydomain.com/page.aspx#target1 。现在,当我从回发返回时,URI 只是 /page.aspx
有没有办法做到这一点?
谢谢!
I have multiple segments on a web page, identified with targets, like this:
<div id="target1" class="section">
<h4><a href="#target1">Buildings by Name</a></h4>
<div>
// button to call server side function
</div>
</div>
So when user clicks "Buildings by Name", the URI changes to
http://www.mydomain.com/page.aspx#target1
i need to call a server side function, which will do some processing. And when i return from the server side script, i want to reload the page with the same targeted URI
http://www.mydomain.com/page.aspx#target1 . Right now, when I return from the postback, the URI is just /page.aspx
is there a way to do this?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会沿着 AJAX 路线走下去。基本上,使用 JavaScript 覆盖标记上的点击处理程序,运行对服务器的调用,并将响应中的数据填充到您的 .
我是执行这些任务的 jQuery 库的粉丝,但是有很多很棒的工具可以提供帮助。
还有一些关于使用 jQuery 进行 AJAX 的教程:
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
http://www.sitepoint.com/ajax-jquery/
I would go down the AJAX route with this. Basically, use JavaScript to override the click handler on your tag, run a call to the server, and populate the data from the response into your .
I'm a fan of the jQuery library for these tasks, but there's a slew of great tools out there to help.
And some tutorials on doing AJAX w/ jQuery:
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
http://www.sitepoint.com/ajax-jquery/
我找到了一种方法来做到这一点。虽然不是最迷人的,但似乎很有效。我用这篇文章作为指导:
以编程方式滚动到锚点标签
因此,在服务器端代码中,处理后,我调用了一个javascript函数:
ClientScript.RegisterStartupScript(this.GetType(), "滚动",
“scrollToResults()”);
然后,在aspx页面中,我放入了javascrpt函数:
I found a way to do this. Not the most glamorous, but it seems to work. I used this post as a guide:
Programmatically scroll to an Anchor Tag
So, in the server side code, after processing, I called a javascript function:
ClientScript.RegisterStartupScript(this.GetType(), "scrolling",
"scrollToResults()");
Then, in the aspx page, i threw in the javascrpt function: