Asp.Net & Event-handles

  • Thread starter Thread starter Francesco
  • Start date Start date
F

Francesco

Hi, i need to catch two events in then same post (a
TextBox_TextChanged and a Button_Click), but sometimes
dot.net catch these events in one post correctly and
sometimes catch only one event (TextBox_TextChanged) and
not the event Button_Click.
Can you help me please?
Thank's.
 
Since only one of these events could happen at a time (you can't change some
text at the same instant you are clicking a button), they will each cause
the page to be regenerated at the server. Once the page has been
re-generated, your event handler (for the event that caused the new page)
will fire.

You could write a generic sub and add a handler for each of the controls to
it and not write any code for the native event handlers:

Sub Do2ThingsAtOnce (byVal Sender As System.Object) Handles
TextBox.TextChanged, Button.Click

Code for textbox
Code for button

End Sub

By including the Sender parameter in the sub declaration, you could then
trap for which object raised the event (if you wanted that capability).
 
Back
Top