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
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

732 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