By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Getting 'Page' in a class method

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
"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

P: n/a
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.