Solved

Adding OnTextChange to Programatically added Textboxes?

Posted on 2008-10-20
2
392 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery datatables, asp.net MVC 9 51
location of a form 2 25
Vb.net threads keep increasing 2 35
reading excel file in .net 2 15
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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