This may help you: http://msdn.microsoft.com/en-us/magazine/cc163941.aspx
Search for the word __CALLBACKID:
To determine the callback mode, the ASP.NET runtime looks for the __CALLBACKID entry in the request collection. If such an entry is found, the runtime concludes that a callback is being performed.
We needed to do this from the app_code file, where access to Page.xxxx objects is not available. This is the code where I ended up:
If Not IsNothing(HttpContext.Current.Request("__CALLBACKID")) Then 'The request is a callback Else 'The request is not a callback End If
This may not be the most pleasant solution, but it does the job. We used Array.IndexOf for a while, but it seems that sometimes this form parameter is returned as lower case (not sure why and how), and Array.IndexOf is case-sensitive.
Be careful when searching for these __XXXX request keys. I remember reading somewhere that it is not recommended to βshortenβ these elements, since their names may change in some future version of .net. Just keep that in mind!
source share