开发者

Change the url in browser from c# codebehind (NOT seo routing or URL rewriting)

开发者 https://www.devze.com 2023-01-15 18:31 出处:网络
I have a website where there is a lengthy list of items to display so I am using Pagination to make the load on server easier.

I have a website where there is a lengthy list of items to display so I am using Pagination to make the load on server easier.

However, I am doing the pagination via Ajax so when the user clicks on Next Page or Previous Page linkbutton, the data repeater is refreshed with ajax.

This was working fine until, people started to click on the item and then click back, it takes them to the first page.

suppose you scan about 10 pages, by clicking on the "Next Page" button. The data changes, but the URL in the browser doesnt. And you think you found what you want so you clic开发者_如何学JAVAk on it, the browser loads different page, and when you click back, the browser takes you to previous page but since the url did not change, you are back to page 1.

Currently, I have removed ajax so the url changes everytime, but I have seen several website re-write the url in browser when ajax even happens, and I was wondering if I could do the same.

Google search for url re-write digs up only seo routing stuff, nothing on what I actually want (i am sure i am not using the right words)

I was interested to know this problem, any clues or leads on this one? thanks!

ps: several questions here were kind of close, but was either too complicated or too deviated. sorry if its a duplicate.


The only part of an URL that you can change in js, client-side, without forcing browser to reload whole page is an anchor part (http://domain/page#anchor - the part after # sign). This part is used by many js application (e.g. Google Picassa), also by silverlight to provide browser history support. You'd have to set an anchor part when navigating to another page of your data. When the page is loaded, just check the anchor part and load appropriate page. Also, you'd have to periodically check for changes - this will happen when user uses back/forward feature in his/her browser. (There could be an event that is fired when that happens, I just haven't found it)

0

精彩评论

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