Sunday, March 29, 2009

AJAX Client State

I've been playing with Microsoft AJAX and the AJAX Control Toolkit. Cool stuff. Judging from the blogs I've read, people have gotten ClientState working, but lots of people just avoid it because it's tricky. I have found 4 hard to debug pitfalls, that will make ClientState mysteriously stop working. In case this is of any use to anyone, here they are. I assume you are using the ACT.

1. Your extender must set EnableClientState to true before base.Init as that is when the hidden field is added.

2. Client state is not loaded until Page.PreLoad

3. Changes made after base.PreRender are lost as that is when state is pushed to the hidden field.

4. The behavior class must inherit from AjaxControlToolkit.BehaviorBase, not Sys.UI.Behavior .