开发者

ScriptManager Control preserves history hash

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜