views:

20

answers:

2

I have a popup window where i store an a arraylist in sessionvariable, when clicking on closebutton (the X in the right top corner) or the cmd input button in the form i want to remove the sessionvariable containing my arraylist. How can i do this?

The popup window is currently closed by a javascript:

function cmdClose_onclick() {
    self.close();
}
A: 

Session variables are stored on the server, so you need to inform the server that something happened on the client, and call an appropriate function to remove the session variable.

There are a couple ways you could do this.

  1. You could make an AJAX request to a page, a page method or a custom HTTPHandler. If you write a custom .ashx file, you could simply make a request to it's URL and have it delete the session variable.

  2. Make your page do a postback when you close the window. You can manually trigger postbacks by calling __doPostBack() in javascript, or just executing a button click or form submit.

I'd go with option #1 if you can.

womp
Im to much of a newbie to choose #1 i will try to call a postback from my function cmdClose_onclick() Thank you for a very good answear!
EasyDot
A: 

I'd suggest getting the javascript to make an AJAX call to a WebMethod which clears the session variable.

David Neale