c# - How to access a global variable from a WebMethod? -


i have following global variable:

private arraylist listselectedunavailables     {                 {             return (arraylist)viewstate["listselectedunavailables"];         }         set         {             viewstate["listselectedunavailables"] = value;         }     } 

i can work in every single procedure of webform.

however, need use in webmethod have in same webform, seems not identify of global variables. so:

how can access global variable webmethod?

a viewstate property depends on having page (.aspx) post view state, that's "variable" stored. webmethod not include full page postback (if post @ all) , there no view state read from. instead may want use session variable like:

    private arraylist listselectedunavailables     {                 {             return (arraylist)session["listselectedunavailables"];         }         set         {             session["listselectedunavailables"] = value;         }     } 

the session stores variable in web server's memory (but related specific browser session). has it's own draw-backs, such being volatile worker process reset, load balancing cosiderations, etc.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -