Reputation: 1
How can I dynamically fire an event for a textbox which is dynamically created? I have used this code:
lab.Click += new EventHandler(lab1_Click);
But this code is not working...
Upvotes: 0
Views: 739
Reputation: 6462
Dynamically created controls have to be re added to page control hirearchy in the Page_Init event with the same ID with which you added it last them.
Then only the ASP.NET framework will match the post back data (which in your case will have data for TextChange) and hook control and the event to its event handler. Else nothings gona happen
Check this article for details
http://support.microsoft.com/kb/317515
Upvotes: 1
Reputation: 55
.net did not allow the Click Event over Text box. If you want that event fires when textbox loses the focus, you can use "lab_validate()" event.
There are many other events for TextBox choose what you feel suitable.
Upvotes: 0