Serve ASP.NET control through custom RequestHandler

  • Thread starter Ricky K. Rasmussen
  • Start date
R

Ricky K. Rasmussen

Hi NG,

Is it possible in any way to serve an ASP.NET server control when the
request is beeing processed by a custom request handler?

In my case I use my own request handler to serve elements that exists as
content in a database, and not as files in the file system. What i want is
to be able to place ASP.NET controls on some of my output, so they can be
served alongside my requested content.

I've tried to create a System.Web.UI.Page instance, add a HtmlForm to its
Controls collection and my ASP.NET control to the HtmlForm. Calling the
Control or Page RenderControl() method provided me with the initial output
of the control, but it seams i need to do a little more work than that.

The Viewstate isn't maintained and the serverside events generated by the
control cannot be caught.

Do I need to manually parse the request for viewstate and serverside events?
Is there a way to do this easily? Or do I end up making my own version of
the ASP.NET RequestHandler?

Could anyone point me in the right direction?

Thanks for your time,
Ricky
 
J

John Saunders

Ricky K. Rasmussen said:
Hi NG,

Is it possible in any way to serve an ASP.NET server control when the
request is beeing processed by a custom request handler?

In my case I use my own request handler to serve elements that exists as
content in a database, and not as files in the file system. What i want is
to be able to place ASP.NET controls on some of my output, so they can be
served alongside my requested content.

I've tried to create a System.Web.UI.Page instance, add a HtmlForm to its
Controls collection and my ASP.NET control to the HtmlForm. Calling the
Control or Page RenderControl() method provided me with the initial output
of the control, but it seams i need to do a little more work than that.

The Viewstate isn't maintained and the serverside events generated by the
control cannot be caught.

Do I need to manually parse the request for viewstate and serverside events?
Is there a way to do this easily? Or do I end up making my own version of
the ASP.NET RequestHandler?

Could anyone point me in the right direction?

If your handler is able to derive from System.Web.UI.Page, then it will _be_
a page, and everything should work.
 
R

Ricky K. Rasmussen

Thanks for your reply John.

I know that deriving from the System.Web.UI.Page creates a ASP.NET Page that
can be served throug the ASP.NET RequestHandler. But what I want to do is to
serve an ASP.NET WebControl throug my own RequestHandler.

I figure this means that I need to programatically create a
System.Web.UI.Page with a HtmlForm containing my control, and then serve the
Page... but how do I do this?

Calling Page.RenderControl() does only create the initial output and doesn't
parse the request for server events and viewstate. Is there a way for me to
make the Page work as if it was served through the ASP.NET RequestHandler?

Thank you for your time,
Ricky
 
J

John Saunders

Ricky K. Rasmussen said:
Thanks for your reply John.

I know that deriving from the System.Web.UI.Page creates a ASP.NET Page that
can be served throug the ASP.NET RequestHandler. But what I want to do is to
serve an ASP.NET WebControl throug my own RequestHandler.

I figure this means that I need to programatically create a
System.Web.UI.Page with a HtmlForm containing my control, and then serve the
Page... but how do I do this?

Calling Page.RenderControl() does only create the initial output and doesn't
parse the request for server events and viewstate. Is there a way for me to
make the Page work as if it was served through the ASP.NET RequestHandler?

No, I meant that your HttpHandler should _be_ a page:

public class MyRequestHandler : System.Web.UI.Page
{
....
}
 

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,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top