casting to page in class library

G

Guest

In my class library I need to access my current Webform (class). As I am
using HttpHandler for ASPX page, following lines of code are throwing error
that {"Specified cast is not valid." }.

// BasePage is custom class derived from Page
BasePage page = (BasePage) System.Web.HttpContext.Current.Handler;

Here System.Web.HttpContext.Current.Handler is returning handler and that is
why not able to cast to page.

How do I get a reference to current executing page in class library?

Any help would greatly be appreciated.
 
G

Guest

How is this class library used? From an ASPX page or a class that is used as
an HTTPHandler or HTTPModule? Or, is it out by itself?

The reason I ask, is it is often easiest to pass in the page, by ref, rather
than set up an intricate setup to figure it out from a class called from the
page or HTTP_____. The reason is the wiring is already in place for both Page
and HTTP_____ classes.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
G

Guest

Thanks for your reply Gregory.

At the end of the day and unfortunately I had to send page as a parameter to
the procedure in class library.
 

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

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top