Friday, October 12, 2007

Ajax: Text value blinks or changes back to what it was before

The situation was I was loading a form. This form had a drop down treeview control that would update a text box. Every time, a selection was made, it would change the value of the text box. But, what was happening was the following:
  • I would choose the drop down value
  • Textbox would change
  • Change the drop down value again
  • Textbox value would change
  • within 1 second, the value would change back.

To fix this, i just put the treeview rendering within a !isPostBack block. This fixed the issue. Essentially what I learned which.. is obvious, is that each time Ajax makes an update it posts back, and, of course this IS a postback. So, make sure if you're loading controls through datasets, etc that you only run it once.

No comments: