views:

166

answers:

2

I need to be able to tell from within a VB.NET class (not a user control) whether or not the current request is a PostBack and/or CallBack (AJAX). In the past I've been able to get information about the request, response, session, etc through HttpContext.Current but I haven't been able to find the Page object in HttpContext.Current.

Is this possible?

+1  A: 

Skirting how to get the Page object, have you considered merely checking if the HTTP method was "POST" in the request object?

Frank Krueger
+3  A: 

HttpContext.Current.Handler will return a System.Web.IHandler, which may happen to be a System.Web.UI.Page. Use the as operator to cast it to a Page, and be sure to check whether it's null before using it.

Francis Gagné
This is perfect! Thanks!
Adam