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
301 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
Comment Utility
Glad I could help!
Raj
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

11 Experts available now in Live!

Get 1:1 Help Now