Solved

Adding OnTextChange to Programatically added Textboxes?

Posted on 2008-10-20
2
391 Views
Last Modified: 2012-05-05
How can I add an OnTextChange event to a textbox I am adding programatically?
0
Comment
Question by:higginsonline
2 Comments
 
LVL 13

Accepted Solution

by:
crazyman earned 500 total points
ID: 22758345
AddHandler txtError.TextChanged, AddressOf txtError_TextChanged

...

Protected Sub txtError_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22759048
You need to recreate each textbox everytime the page is created (even during postbacks). In addition to this you need to assign an id to each textbox, this id must remain constant. so if you are creating textboxes inside the a loop then something like the following will do
textbox(i).ID = "textBox" + i.ToString()
The reason for setting an id is that, after the control is created during postbacks, it will map onto the correct event handler for that instance based on the ID.
Finally, Do what CrazyMan suggested.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question