Thursday, July 21, 2011

Using UpdatePanel

I had to modify a program where all the data was loaded from the client side using XML and tables. The things I needed to add had already been done in another system and was implemented using the server side code. So, I had three options.
1) Manipulate the new additions from the client side, which would mean I had to start from scratch for that code, since it was server side code.
2) I could move the old stuff to the server side, which would necessitate creating server side code.
3) Leaving the old stuff alone and adding the new stuff on the server side. I chose this option. But it presented some challenges of its own, name managing the state when adding the new fields on postback.
I looked for various options and finally determined to use the UpdatePanel. This would allow me to only update the section of the screen I needed to and the remaining portion of the screen would not change.
Basically, you wrap you controls in the ContentTemplate option of the UpdatePanel and define the triggers that will cause the update for the portion of the screen we are updating.
Another work around involved how the original program functioned. The client code would execute the load mechanism to populate the screen when the program loaded. And because everything else was handled on the client side, it was only invoked 1 time. However, once you start calling server side, this code gets executed on each postback. So, I had to move this code to a function and use the client script manager to invoke this code only on program load.

No comments:

Post a Comment