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
309 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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