开发者

ScriptManager Control preserves history hash

开发者 https://www.devze.com 2023-02-16 20:15 出处:网络
I am using a ScriptManager control to load search results from server web services. There is a text box and button on the page where the user enters their search terms. When they submit their search t

I am using a ScriptManager control to load search results from server web services. There is a text box and button on the page where the user enters their search terms. When they submit their search there is a Response.Redirect that is called to the search page. I use the ScriptMana开发者_如何学Pythonger's history function to track filtering that the users can do. If you are familiar with this function the URL ends up looking something like this:

http://somesite/search.aspx?q=giant+dog#color=red&hair=long

My problem is that if the users deices to do another search with the text box and button on the search.aspx page, which causes a response.redirect, the query string changes but the hash history stay a part of the URL. This does not make sense to me because from what I understand of the Response.Redirect("someURL") it should act like it is sending you to a new page regardless if it is going to the same page it left.

I know I can set window.location.hash = "#" but I was hoping there was a cleaner way than that on the server side.

Please help! :-)


This is an old post, but I thought that I would add the solution in case anybody else was looking for this. I ran into the same problem, where the history point was being maintained across post backs to the server when a Response.Redirect() call was made. I'm not sure why this is happening and it seems counter-intuitive to me. But I believe the ScriptManager is doing something to carry the history point over.

The answer is to put your control that's issuing the Response.Redirect() call in an UpdatePanel. So, in my case, I have a button that has an event handler where a redirect is being issued. Without the UpdatePanel, the history point is preserved. With the UpdatePanel wrapping the button, all works as expected.


You can invoke AddHistoryPoint method of the ScriptManager, before Redirect.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号