Solved

How do I get a page to bind when the page is loaded when the browser back button is clicked  In asp.net c#

Posted on 2011-02-25
4
306 Views
Last Modified: 2013-12-17
How do I get a page to bind when the page is loaded when the browser back button is clicked  
0
Comment
Question by:bmanmike39
  • 3
4 Comments
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 500 total points
ID: 34986306
Back button click of browser is cannot be directly identified by any way as it is a client side browser button event! Even can't be identified by client side script.
When you click Back button, browser just reloads the previous page's rendered HTML - No events are triggered for this browser button click event.
To be more clear, IE Back button is completely independent of the content of your page.

Since there are no direct methods to acheive this, you can try some alternative methods
One option is disable the caching, so that even on click back button previous page will not load

Or

BUT YOU CAN CATCH PAGE UNLOAD EVENT USING JQUERY, when user clicks on IE back button

This method - I already tested and working fine.

The above link says about showing a message box. Instead of the message box, you need to place a dummy button in your aspx page . Put you page_load codes into a function. Call that function in page_load. Call the same function in dummy button click (this button should be hidden)

Hope this helps!
Raj
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34986326
From the link that I posted above.
Attached the js files that I modified for my purpose
 jquery.js
 navigateaway.js
 navigateaway.min.js
// Javascript file references in ASPX Page
    <script language="javascript" type="text/javascript" src="js/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="js/navigateaway.min.js"></script>

Open in new window


// Dummy button
.....
 <asp:Button id="Dummybtn" runat="server" style="display:none;" />
    </form>

Open in new window

// Code-Behind Button click event

 Protected Sub Dummybtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dummybtn.Click
        pageLoadCodes()
    End Sub

Open in new window


If you check inside navigateaway.min.js file , you can see the code
$('#Dummybtn').trigger('click');

Open in new window

which calls the button click

I tried to explain the steps that I done to reduce your learning process. Not sure whether I missed anything.

Raj
0
 

Author Closing Comment

by:bmanmike39
ID: 34987571
Thanks!
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34988122
Glad I could help!
Raj
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now