如何在Asp.net中重写URL而无需回发 [英] How to Rewrite URL without postback in Asp.net
本文介绍了如何在Asp.net中重写URL而无需回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一种情况,我需要在单击按钮和按钮时更改页面的URL.执行该按钮的Click事件的代码执行.我不想重定向页面,因为我正在使用更新"面板&希望保留在同一页面上更改URL.
我想知道是否有可能.据我所知:
Hi,
I have a situation where I need to change the URL of page on click of Button & perform the Execution of code for the Click event of that Button. I don''t want to redirect the page, as I am using the Update panel & want to remain on the same page & change the URL.
I want to know is it possible. As I have came to know about :
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");
但它可以在最新的浏览器上运行并非所有浏览器.
谢谢
TusDev1
But it''s working on latest browsers & not all browsers.
Thanks
TusDev1
推荐答案
确实,并非所有浏览器都支持推入历史记录.
使用location.hash可以帮助您吗?
example.com/foo#bar
example.com/foo#baz
这将更改url而不重新加载整个页面.
It''s true that pushing into the history is not supported on all browsers.
Would using the location.hash help you?
example.com/foo#bar
example.com/foo#baz
This changes the url without reloading the whole page.
这篇关于如何在Asp.net中重写URL而无需回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文