How can this be done? Does this exclude the UpdatePanel functionality when it's done?
+6
A:
The reason that it supports only static methods is that no page is instantiated. This means that there is no page instance, so of course instance methods cannot be called. This also means that UpdatePanel functionality does not run when you do this.
A workaround is that within your static method you can instantiate the page itself and then do whatever you want. However, keep in mind that things like the page lifecycle won't run.
To get the current context you can use HttpContext.Current
, which is a static property. Once you have that you can access things like session or profile and get information about the state of the site.
If you tell us more about your scenario there might be a better solution.
Eilon
2010-01-12 23:17:53
well, I want to do something on the server, that doesn't require any changes in the UI, but require access to the Session object of the user.
Danail
2010-01-12 23:22:39
I'm not 100% sure, but I think that from your static method you can use HttpContext.Current.Session and change whatever you want.
Eilon
2010-01-12 23:43:13
Yep, that makes this method perfectly usable :) 10x a lot!
Danail
2010-01-13 10:51:00