Textchanged event fired on every post

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?
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top