473,396 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to build web forms dynamically - AddHandler

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



Apr 10 '06 #1
2 2388
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

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"bill" <be****@datamti.com> wrote in message
news:Ol**************@TK2MSFTNGP04.phx.gbl...
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


Apr 10 '06 #2
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:Ol**************@TK2MSFTNGP04.phx.gbl...
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

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"bill" <be****@datamti.com> wrote in message
news:Ol**************@TK2MSFTNGP04.phx.gbl...
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



Apr 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
3
by: Forconi Boris via .NET 247 | last post by:
Hi, I'm working on a project in witch I have to list data(products that can be selected with a certain quantity) from anXML document, with key words entered by the user. A Table isdynamically created...
5
by: karthick raja | last post by:
Am experiencing a problem intercepting the events from controls added dynamically to a Placeholder control at runtime. Is there any way that I can write an event handler on the page which will be...
2
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status)...
2
by: MLS | last post by:
The documentation on dynamic handlers comes across as abiguous. Perhaps somebody could help set me straight? I have a situation where I need to dynamically create several usercontrols of the...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
1
by: bill | last post by:
I'm using VS2005. I am dynamically adding a Textbox control to a Placeholder control in the page_load event of the form, but the event handler isn't firing. What am I doing wrong? Thanks...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
6
by: RSH | last post by:
Hi, i have a situation where I need to dynamically create objects in a loop. My question surrounds intantiation naming in such a scenerio. Below is a snippet that is basically hardcoding each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.