I’ve got a usercontrol that has a <asp:TextBox> with autopostback set to true. When the user types text in and moves off the textbox, asp.net fires a postback event. However, it isn’t handled specifically by the textbox, but is instead simply a postback – the page_load fires and then life goes on.
What I need is a way to know that this textbox fired the event. I then want to fire my own custom event so that my main page can subscribe to it and handle the event when the textbox changes.
At first I thought I could capture the sender – I was assuming that the sender would be the textbox, but it appears to be the page itself.
Anyone have any thoughts?
I think you’re missing something, so I want to explain it step by step :
your textbox should be something like that :
and in your codebehind you shhould have an event like that :
NOTE : if you want to attach your event in code-behind you can do this by :
but if you talking about custom controls, you should implement IPostBackDataHandler interface to raise events.