How to Disable back button
-
Hi All, In my application user filter,serch items in the gridview but when he/she click the button then all item serched items he losed. I want to disable back button.for this I m using following code <script type="text/javascript"> function noBack(){window.history.forward()} noBack(); window.onload=noBack; window.onpageshow=function(evt){if(evt.persisted)noBack()} window.onunload=function(){void(0)} </script> but it breaks for go to previous page but in this situation user is in same page. thnks to all.........
-
Hi All, In my application user filter,serch items in the gridview but when he/she click the button then all item serched items he losed. I want to disable back button.for this I m using following code <script type="text/javascript"> function noBack(){window.history.forward()} noBack(); window.onload=noBack; window.onpageshow=function(evt){if(evt.persisted)noBack()} window.onunload=function(){void(0)} </script> but it breaks for go to previous page but in this situation user is in same page. thnks to all.........
As I think, the best way to disable the back button is "don't create the history of the page". Because may be in some browser's, disable code will not work. Here is the code to remove the history of a particular page:- <% Response.Expires = 0 Response.ExpiresAbsolute = DateTime.Now.AddDays(-1) Response.AddHeader("cache-control", "private") Response.CacheControl = "no-cache" %> Hope this will help you......
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."
-
As I think, the best way to disable the back button is "don't create the history of the page". Because may be in some browser's, disable code will not work. Here is the code to remove the history of a particular page:- <% Response.Expires = 0 Response.ExpiresAbsolute = DateTime.Now.AddDays(-1) Response.AddHeader("cache-control", "private") Response.CacheControl = "no-cache" %> Hope this will help you......
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."
What part/tag of the .aspx page or (event handler) code behind does this code fits?
-
What part/tag of the .aspx page or (event handler) code behind does this code fits?
you can put this code on above the HTML tag of your .aspx page.
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."
-
you can put this code on above the HTML tag of your .aspx page.
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."
Thanks for your reply.
-
As I think, the best way to disable the back button is "don't create the history of the page". Because may be in some browser's, disable code will not work. Here is the code to remove the history of a particular page:- <% Response.Expires = 0 Response.ExpiresAbsolute = DateTime.Now.AddDays(-1) Response.AddHeader("cache-control", "private") Response.CacheControl = "no-cache" %> Hope this will help you......
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."
Thnks For Reply I have used this code but it is going to back...... in all browsers(IE,Mozila)
-
Thnks For Reply I have used this code but it is going to back...... in all browsers(IE,Mozila)
This code has to be used on previous page. Means, if you want's to disable the "back" button of page "zxc.aspx", so you have to put this code in previous page of "zxc.aspx", from which you have come to "zxc.aspx". i.e. if you have come from "test.aspx" (on click of any link) to "zxc.aspx", then you have to put this code on "test.aspx" page. Try this. This will definitely work in all browsers.
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."
-
This code has to be used on previous page. Means, if you want's to disable the "back" button of page "zxc.aspx", so you have to put this code in previous page of "zxc.aspx", from which you have come to "zxc.aspx". i.e. if you have come from "test.aspx" (on click of any link) to "zxc.aspx", then you have to put this code on "test.aspx" page. Try this. This will definitely work in all browsers.
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."
Thnks Dear, In my application user is always in same page.because he is filtering,sorting and serching items in grid then grid is showing data according to filtering,sorting and serching but it open in same page always not in other page...... Thnks....
-
Thanks for your reply.
Your welcome
Regards... Vijay Jain :)
"One thing you can't recycle is wasted time."