Getting 'Page' in a class method

G

Guest

I am using a third party product that requires a reference to a page, Me.Page
for example. I would like to use this product in a function, in a vb class,
that I am writing. I know that I can pass the page, as an object, into the
method, but I was wondering if there was a way to get the current page,
inside a vb class, using a .NET method.

Thanks,
Leonard
 
J

John Saunders

Leonard Rutkowski said:
I am using a third party product that requires a reference to a page,
Me.Page
for example. I would like to use this product in a function, in a vb
class,
that I am writing. I know that I can pass the page, as an object, into
the
method, but I was wondering if there was a way to get the current page,
inside a vb class, using a .NET method.

HttpContext.Current is the current instance of HttpContext (or null, if
you're not inside of a request). HttpContext.Handler is the IHttpHandler
instance which is processing the request. If that handler is a Page, then
you can cast to Page:

DirectCast(HttpContext.Current.Handler, Page)

John Saunders
 
G

Guest

Hi John,
Just what I was looking for. I had looked through the help, but didn't
quit understand what was needed.

Thanks,
Leonard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top