Textchanged event fired on every post

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I used the textchanged event of textbox and set the autopostback property to
true. The textchanged event should fire when the content of the textbox is
changed and user tab out of the textbox control. However, textchanged event
fires whenever there is a postback, even when I click a button that send
postback. Can anybody tell we what change I should make so that textchanged
event only fire when the content is changed?
 
I've done it the following way, but I wonder if there isn't a better one?

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
Static PrevText As String = ""
If TextBox1.Text = PrevText Then Return
PrevText = TextBox1.Text
... perform other tasks
End Sub
 
Back
Top