I have an ASP.NET Web Forms web site. It has a page inside of a master page. There are a lot of items on this page that do a post-back, but with a different GET parameter. So for example I am on a http://mysite/mypage?p=1, and then I click on some item and go to http://mysite/mypage?p=2, and so on. Obviously, the master page doesn’t change, the only thing that changes is the URL and the page content, so actually there is no need to do a full post-back. So I would like to rewrite the page to do a partial AJAX-style post-back and to have the URL changed (I want the users to be able to make bookmarks and do proper browser history navigations). But how do I do that?
I can use UpdatePanel for example, and I can make all items to be some sort of buttons that do a post-back instead of being hyperlinks that do page navigations. But my URLs will remain the same, and this is bad.
I would prefer an answer that uses either UpdatePanel control or jQuery library, but answers that utilize other technologies are also fine because they might give me a hint on solving my problem.
The only way to achieve this is to dynamically load content while using “#” in the URL. For instance, http://mysite/mypage#1, http://mysite/mypage#2. This enables the ability to change the URL on demand without having to re-direct while performing AJAX type functionality. The URL can be bookmarked as well.
Of you course, you’ll need to write some Javascript to parse out the characters after # or some type of event listener when a partial postback occurs to pass in different parameters.
I’ve implemented this a few times already and this is the only thing that I know of that solves the issue you’re having. Twitter was somewhat an inspiration at that time.