Search code examples
asp.netvb.nettextboxformview

FormView TextBox Focus


What events are triggered when a focus is set into TextBox? And similarly what events are triggered when focus is set out from TextBox?

I have several TextBoxes in a FormView. I have tabbed into a Textbox. How can I write a generic code to find out the ID of this TextBox programatically (without using JavaScript)? How can I get the text value from this TextBox?


Solution

  • You are asking 2 separate questions. For the first one - what events are triggered when focus is set in the browser (assuming in VB code) - the answer is none. A quick scan of the MSDN documentation for the control for exposed events here should confirm that. You would have to respond to focus changes on the browser via javascript in some manner.

    For the second question, if you can live with responding when the page is posted back to the server rather than on focus change. You can assign all your textboxes to the same TextChanged event, and then the sender property will be the textbox which had the change. Connecting Multiple Events to a Single Event and/or AddHandler Statement