how to build web forms dynamically - AddHandler

B

bill

I am building a web form dynamically using VB 2005.

I add several textbox controls, radio button controls, checkbox list
controls, etc. to a placehoder control on the page, and I want to add an
event handler to handle the TextChanged or other appropriate event for all
the text boxes (they do not autopostback). When the page posts I want to
collect the data in the text boxes and save it to a database.

I'm not sure when/where I should add the textbox controls and link up the
event handlers, and how to capture the contents of the textboxes in the
event handler and identify which textbox fired the event.

I have attempted this using

AddHandler textbox1.TextChanged, AddressOf ehandler

but I can't get it to work!

Thanks for your help
Bill
 
K

Karl Seguin [MVP]

The handler needs to be added on postback during (or before) page_load. This
means the controls themeselves also need to be re-added before/during that
time.

Karl
 
B

bill

I see the problem, I was only adding the controls If NOT IsPostBack, so i
wasn't 're-adding' them at all. That was the piece of the puzzle I missed.
Now it works fine. Thanks for your help.


"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:[email protected]...
 

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,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top