I have my page where i have added back / next button in my page, to navigate back next, same as browser back next button, I have seen in browser if there no history of page, than browser back/next button is disabled, if forward history is not there than
next button is disabled, vice versa with back button, can i do same with my back next button used in my page, i am using same functionality as browser. Note i have mutliple pages in my site. so it should not stop other navigation.
u cannot do it the way browser works.... i.e. you cannot determine if history.back is null or not...
u can check if history.length is 0... then u can disable both back and next buttons.... but, once user navigate for first time... history.length becomes more than 0... and then u can not determine whether u r back to first page or last... that means cannot
decide on whether back or next button should be disabled or not...
however, u can do history.back() or back button click and history.forward() on next button click... and if user is on first page... then clicking on back button will simply not work...
hope this helps...
Cheers!
KK
Please mark as Answer if post helps in resolving your issue
My Site
I don't want to detect browser back button, I have a page in which i have taken back and forward button
which have code, window.history.back() and window.history.forward()
when my page is loaded firsttime i want this buttons to be disabled, than when i do any action like drop down selection, back button should be enabled, now when back button is clicked next should be enabled.If there is no back than back should be disabled,
vice versa with forward button.
please help as this i main requirement of our project
In stead of using window.history, you'll write your own data structure to save pages user has visited.
For example, use an array to store these urls. Then convert the array to text that can be saved in localStorage if you are in IE8 and up, otherwise use cookies. Every time you are going back and forward, you'll set a point to which url in that data structure.
If it the first url, then disable the button.
priyapatil91
Member
24 Points
20 Posts
Disable back / next button
Mar 16, 2012 09:18 AM|LINK
I have my page where i have added back / next button in my page, to navigate back next, same as browser back next button, I have seen in browser if there no history of page, than browser back/next button is disabled, if forward history is not there than next button is disabled, vice versa with back button, can i do same with my back next button used in my page, i am using same functionality as browser. Note i have mutliple pages in my site. so it should not stop other navigation.
kedarrkulkar...
All-Star
34497 Points
5550 Posts
Re: Disable back / next button
Mar 16, 2012 09:45 AM|LINK
u cannot do it the way browser works.... i.e. you cannot determine if history.back is null or not...
u can check if history.length is 0... then u can disable both back and next buttons.... but, once user navigate for first time... history.length becomes more than 0... and then u can not determine whether u r back to first page or last... that means cannot decide on whether back or next button should be disabled or not...
however, u can do history.back() or back button click and history.forward() on next button click... and if user is on first page... then clicking on back button will simply not work...
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
chetan.sarod...
All-Star
65759 Points
11153 Posts
Re: Disable back / next button
Mar 19, 2012 03:11 AM|LINK
Please refer to detecting Browser back button
http://www.bajb.net/2010/02/browser-back-button-detection/
http://forums.asp.net/t/1777379.aspx/1
Based on this button's state you can set your button's visibility
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
priyapatil91
Member
24 Points
20 Posts
Re: Disable back / next button
Mar 20, 2012 04:09 AM|LINK
I don't want to detect browser back button, I have a page in which i have taken back and forward button
which have code, window.history.back() and window.history.forward()
when my page is loaded firsttime i want this buttons to be disabled, than when i do any action like drop down selection, back button should be enabled, now when back button is clicked next should be enabled.If there is no back than back should be disabled, vice versa with forward button.
please help as this i main requirement of our project
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Disable back / next button
Mar 20, 2012 05:00 AM|LINK
Hello
In stead of using window.history, you'll write your own data structure to save pages user has visited.
For example, use an array to store these urls. Then convert the array to text that can be saved in localStorage if you are in IE8 and up, otherwise use cookies. Every time you are going back and forward, you'll set a point to which url in that data structure. If it the first url, then disable the button.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
chikkanti
Member
270 Points
80 Posts
Re: Disable back / next button
Mar 20, 2012 09:02 AM|LINK
you can maintain history in viewstate and check for history
if u found any history in viewstate enable button
if u don't find any history disable...