469,929 Members | 1,557 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

Getting 'Page' in a class method

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
Nov 22 '05 #1
2 1817
"Leonard Rutkowski" <Le**************@discussions.microsoft.com> wrote in
message news:33**********************************@microsof t.com...
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
Nov 22 '05 #2
Hi John,
Just what I was looking for. I had looked through the help, but didn't
quit understand what was needed.

Thanks,
Leonard

"John Saunders" wrote:
"Leonard Rutkowski" <Le**************@discussions.microsoft.com> wrote in
message news:33**********************************@microsof t.com...
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

Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Leonard Rutkowski | last post: by
4 posts views Thread by Larry Tate | last post: by
2 posts views Thread by John Lau | last post: by
5 posts views Thread by Nathan Sokalski | last post: by
6 posts views Thread by scottyman | last post: by
reply views Thread by cnys | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.