Changing values via Ajax/Atlas and maintaining state
The advantage of Ajax, Atlas or CallBacks is that we can refresh regions in a page without having to reload the entire page.
One of the problems I have run into is preserving the state of the refreshed region when my page is semi-ajax (ie. it may use either ajax or the browser’s submit mechanism to postback data).
Consider this simple example:
You change the value of a Label control like so:
document.getElementById("Label1").innerHTML = "Hello World!";
When you postback the page, your application has no way of knowing the change that occurred. This causes the Label control to be rendered the way it was before you made the change using ajax.
To work around this, I use a hidden input tag that “shadows” the value(s) being populated. The hidden input tag’s value is changed through script or code behind if the control it is shadowing changes value.
This way, when a postback occurs, the application is aware of the change by reading the hidden input field.
I am sure there is a better way to do this.