Use Page Event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George

    Use Page Event

    How can I use an event of "Page" control other than the Page_Load?

    I want to use the event "Unload" to execute some code when the page closes.
    How can I declare it? The peculiar thing is when I declare the function in
    the back code

    protected void Unload(object sender, EventArgs e)
    {
    //*** Some Code
    }

    the function is executed during the Page Load process.

    How can I control the closing of an aspx Page? Not with Javascript but with
    C#

    Thanks

    George

  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: Use Page Event

    asp.net does note really handle client events (it just fakes it).

    asp.net sends html to the browser. at some point the browser may postback
    the form data via the user hitting a sumbit button, or client javascript
    calling form.submit(). an example of this is a linkbutton whicg uses
    javascript, or setting autopostback on a dropdown.

    the only to way really handle browser events is with javascript. there is no
    event tired to browser close. the closest yu can get is page unload wich is
    fired anytime a page in the browser is repolaced with another.

    -- bruce (sqlwork.com)


    "George" wrote:
    How can I use an event of "Page" control other than the Page_Load?
    >
    I want to use the event "Unload" to execute some code when the page closes.
    How can I declare it? The peculiar thing is when I declare the function in
    the back code
    >
    protected void Unload(object sender, EventArgs e)
    {
    //*** Some Code
    }
    >
    the function is executed during the Page Load process.
    >
    How can I control the closing of an aspx Page? Not with Javascript but with
    C#
    >
    Thanks
    >
    George
    >

    Comment

    • Mark Rae [MVP]

      #3
      Re: Use Page Event

      "George" <gvarelas@casin orio.grwrote in message
      news:9D43700B-1B3A-4825-BCA6-09968016F692@mi crosoft.com...
      How can I control the closing of an aspx Page? Not with Javascript but
      with C#
      As Bruce has explained, you can't...

      C# runs on the server - JavaScript runs on the client


      --
      Mark Rae
      ASP.NET MVP


      Comment

      • Munna

        #4
        Re: Use Page Event

        Hi

        "Unload is called after the page has been fully rendered, sent to the
        client, and is ready to be discarded. At this point, page properties
        such as Response and Request are unloaded and any cleanup is
        performed."

        so it executes on server... not in client side...

        Best of luck

        -----------
        Munna




        Comment

        Working...