Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6636941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:15:00+00:00 2026-05-25T23:15:00+00:00

When a user leaves a page it fires of the Page_Load event again. How

  • 0

When a user leaves a page it fires of the Page_Load event again. How can I tell in code_behind that this is happening so in can avoid running the custom functions as the code in the Page_Load does not really need to be ran when leaving the page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:15:01+00:00Added an answer on May 25, 2026 at 11:15 pm

    When a user leaves a page it fires of the Page_Load event again

    What do you mean by leaving a Page? Closing the browser or clicking Back button on browser? Or moving to another Page? Page_Load method is fired when on Loading Page or when Postback occurs on the same Page, but not leaving it.

    Before you start any operations, you can (and you should) ensure that client is still connected and use HttpResponse.IsClientConnected property.

    The IsClientConnected property returns false when the following conditions are true:

    1. The connection to the client was terminated. This can occur if the Close method was invoked, or if the client stopped execution of the Web page or browsed to another page.
    2. The HttpWorkerRequest object that is handling the request is null or the HttpWorkerRequest.IsClientConnected method returns false. If a custom HttpWorkerRequest object handles the request, then the HttpWorkerRequest.IsClientConnected method might be set based on custom criteria. For example, the custom worker request might force a time-out after a period of time.

    http://msdn.microsoft.com/en-us/library/system.web.httpresponse.isclientconnected.aspx

    EDIT

    Switching tabs usually fires normal Postback, to detect it you should use:

    private void Page_Load(object sender, System.EventArgs e)
    {
        if (!Page.IsPostback)
        {
           //this is first load of this page
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this page animation which when the user leaves the page the document
When user leaves page where plays youtube video playback is not stops. How can
I need to send a post request when the user leaves the page in
User Story: Action for Facebook that has open graph object. For this I need
I'm trying to perform a post query when the user leaves the page. The
I want to make an AJAX call before the user leaves the page (so
When a user leaves one page of my website, there should be a warning
When ever user leaves chat page (Either by logging out or just by simple
I want to send an ajax request when a user leaves a page or
When a user leaves a page, I need to ask him if he wants

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.