Page Close Event In ASP.NET??

Discussion in 'ASP .Net' started by =?Utf-8?B?VmlubnkgVmlubg==?=, Apr 28, 2004.

  1. IS There An EventHandler or Script To Catch When The Page Is Closing(similar to the Closing event in WInforms)

    Thanks
    =?Utf-8?B?VmlubnkgVmlubg==?=, Apr 28, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?VmlubnkgVmlubg==?=

    Matt Berther Guest

    Hello =?Utf-8?B?VmlubnkgVmlubg==?=,

    Depending on what you're trying to do... If you're trying to catch the browser window closing, then you'll need to do that via client side javascript (<body onUnload="someMethod()"/>

    If you want to trap when the page gets unloaded on the server side (ie: after it's sent to the browser, your event is Page.Unload.

    > IS There An EventHandler or Script To Catch When The Page Is
    > Closing(similar to the Closing event in WInforms)?
    >
    > Thanks
    >

    --

    --
    Matt Berther
    http://www.mattberther.com
    Matt Berther, Apr 28, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?VmlubnkgVmlubg==?=

    David Jessee Guest

    If the user closes out the browser without something posting that data back
    to the server, then you're out of luck.
    However, if you keep track of what the user's doing, and place that data
    somewhere in their session, or in a databade, then you could do something
    when the user's session ends. (a result of them closing out the browser).

    If you're working with IE only, then I guess you could create a client-side
    javascript function that created an xmlhttp (ActiveX) object and posted the
    form's information to the server as an XML document (where this function
    executes on the page's onUnload Event). But that also means the function
    would run every time the page posts back too. To get around this, you could
    check the event's X,Y coordinates to see if it happened inside of the window
    (is it happened at a negative Y coordinate, then the user clicked "x")

    These are just sone random musings...Hope they help


    "Vinny Vinn" <> wrote in message
    news:...
    > I apologize for not be clear as to what i am trying to do.
    >
    > When the page is x out (not Redirected) i would like to save (to a

    database) any data that the user entered.
    >
    David Jessee, Apr 29, 2004
    #3
  4. David
    Thanks for your suggestions
    How would i get the x,y coordinates from the unload event?
    =?Utf-8?B?VmlubnkgVmlubg==?=, Apr 29, 2004
    #4
  5. =?Utf-8?B?VmlubnkgVmlubg==?=

    Matt Berther Guest

    Hello David,

    I've recently done something quite similar to this. However, I set up a web service that would accept the data to write it into the database.

    The client browser had <body onUnload="saveData();">, with a reference to a javascript file that defined the saveData method.

    This method was responsible for generating the SOAP envelope and using the XMLHTTP object to submit this to the web service.

    A fairly clean implementation, if I do say so myself, given that we were targeting only IE5+.

    > If you're working with IE only, then I guess you could create a
    > client-side javascript function that created an xmlhttp (ActiveX)
    > object and posted the form's information to the server as an XML
    > document (where this function executes on the page's onUnload Event).
    > But that also means the function would run every time the page posts
    > back too. To get around this, you could check the event's X,Y
    > coordinates to see if it happened inside of the window (is it happened
    > at a negative Y coordinate, then the user clicked "x")


    --
    Matt Berther
    http://www.mattberther.com
    Matt Berther, Apr 29, 2004
    #5
  6. =?Utf-8?B?VmlubnkgVmlubg==?=

    martinkwong

    Joined:
    Aug 24, 2007
    Messages:
    1
    how to set a limit to number of popups?

    currently i had this weird user requirement and i was wondering if you guys got some ideas how to handle.

    i need to popup a new popup everytime this particular button clicks
    the maximum number of the popup is for example : 5

    when the number reached 5, no more pop up is allowed.

    if the current no.popup is 3, then u can only allow u click 2 more times and so on...kind of allowing only 5 instances of a popup

    i was thinking of making a queue/counter which whenever there is a click on that button, they should be checked whether the queue/counter isit fulled or not, else allow it to popup using javascript. however, whenever i close the popup, is there anyway to make server knows the queue/counter to remove one slot from the queue?

    i was just wondering is it possible to be done via javascript and asp.net2.0.
    i know this is a stupid user requirement, but i was cracking my brains to find a logic to get this work and hope some one can give me some guidance, or am i thinking the wrong logic which makes thing complicated. thanks

    :argh:
    regards,
    martin
    martinkwong, Aug 24, 2007
    #6
  7. =?Utf-8?B?VmlubnkgVmlubg==?=

    werddomain

    Joined:
    Oct 24, 2011
    Messages:
    2
    werddomain, Oct 24, 2011
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?a2lvc215?=

    windows close event with asp.net

    =?Utf-8?B?a2lvc215?=, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,443
    =?Utf-8?B?a2lvc215?=
    Jan 19, 2004
  2. Iñaki Baz Castillo
    Replies:
    7
    Views:
    849
    Iñaki Baz Castillo
    Jan 12, 2010
  3. Replies:
    2
    Views:
    460
  4. Replies:
    0
    Views:
    493
  5. Mike Scirocco
    Replies:
    4
    Views:
    265
    Mike Scirocco
    Apr 5, 2007
Loading...

Share This Page