Component in WebForm

S

Shawn B.

Greetings,

Is it possible to get a reference to the Page object of an ASP.NET page from
within a Component that has been placed on the page?

I want the component to be available on the page and when the page renders I
want it to be able to inject something into the Page Response stream but the
Component object itself is very non-visual and for that reason I thought it
would be better not to have it as a control.


Thanks,
Shawn
 
J

John Saunders

Shawn B. said:
Greetings,

Is it possible to get a reference to the Page object of an ASP.NET page from
within a Component that has been placed on the page?

I want the component to be available on the page and when the page renders I
want it to be able to inject something into the Page Response stream but the
Component object itself is very non-visual and for that reason I thought it
would be better not to have it as a control.

If it's going to emit something, even if it's "non-visual", then you should
probably make it a control.
 
D

David Rothgery

Shawn B. said:
Greetings,

Is it possible to get a reference to the Page object of an ASP.NET page from
within a Component that has been placed on the page?

Use HttpContext.Current .
HTH.
 
S

Shawn B.

That didn't work because, while I could get access to the Request/Response
objects, I need the page itself.

So, I casted the HttpContext.Current.Handler to a page object and that
worked.

The only last thing I need to figure out is how to get the name of the
instance of the Component. There is a Name property in the property editor
for the component but there is no Name for the object (or ID) so unless I
can figure out how to uniquely identify a particular instance of the
component then I still am not there.

Is there a way I can get a handle to an instnace of the component attached
to the Form?


Thanks,
Shawn
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top