views:

109

answers:

1

I have a list of objects which I store in the session. This list then appears on a web page with little "X"s next to each item. When one of them is clicked I use Javascript to remove the item from the list on the page and then I send an AJAX call to the server to remove the item from the list in the session also. Here's where things get a little tricky. I'm using a ScriptMethod that looks like this (C#):

[System.Web.Services.WebMethod, System.Web.Script.Services.ScriptMethod]
    public static void removeListItem(string itemNumber)

The problem is that this is a static method which means I don't have access to the Page variable which in turn means I don't have access to the Session. Now the sessionID is sent with the request (which I also can't access) and the server has the session so I would assume that there's some way to take that ID and access the session. Is there a way to access the session from a static method like this? Thanks!

+5  A: 

Use HttpContext.Current.Session instead of direct call to Session

more info in this article

Amr ElGarhy
+1 Fastest gun in the west.
Greg
I knew it'd be something simple like that. Thanks!
Peter