开发者

How to remove sessionvariable when closing popup window?

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 ses开发者_开发问答sionvariable containing my arraylist. How can i do this?

The popup window is currently closed by a javascript:

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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜