Adding Server Control dynamically in CodeBehind

S

Serge

Hi,

Is there a way to add server controls on HttpResponse
without using a PlaceHolder control?

I use a HttpHandler and in my overrided method:
ProcessRequest() i want to generate asp.net server
controls that will be rendered in html tags...

do you know some cool web sites related to this issues?
could someone giving me some tips of how to do it?

Thanks a lot.

Serge
 
J

John Saunders

Serge said:
Hi,

Is there a way to add server controls on HttpResponse
without using a PlaceHolder control?

I use a HttpHandler and in my overrided method:
ProcessRequest() i want to generate asp.net server
controls that will be rendered in html tags...

do you know some cool web sites related to this issues?
could someone giving me some tips of how to do it?

I think that if you want to use server controls, your HttpHandler will need
to derive from System.Web.UI.Page. You should then be able to add an
HtmlForm control to the page, and add controls to the HtmlForm's Controls
collection.
 
J

John Saunders

Serge said:
Thanks John, I just tried. It works I can add and handler
wish derive from System.Web.UI.Page

Now the problem is that i cannot create a new HtmlForm in
my Form_load and add a control into it.

Do you mean "Page_Load"?

If so, could you give more detail about what doesn't work? Is an exception
thrown when you try to create the new HtmlForm?
 
J

John Saunders

I just successfully added an HtmlForm to a HttpHandler derived from
System.Web.UI.Page. This application used to have the handler load a
user control which contained the form. I removed the form from the user
control and then added it in the Init event of the handler. The
application worked with no problems. It also worked if I added the form
in the OnLoad method.

John Saunders
(e-mail address removed)
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top