View Full Version : ext:button and AJAX

Jul 01, 2008, 11:45 AM
Hi there,

I am using the excellent viewport control, and in my center panel I have a ext:button that does an update on a database. Using the ext:button I am running the code that preforms the update in the codebehind, but i was wondering how I would achieve this without having a whole postback occuring as this destroys all the contents of my pannels etc...

I realise this may well not be anything to do with Coolite and more a ASP.NET ajax issue, I am just a little new to AJAX and maybe need a hard punch in the right direction as to how to get the ext:button to run some serverside code without killing stuff!

Thanks for any help

Jul 01, 2008, 12:50 PM
First, I would investigate why a postback will destroy your UI controls. Everything on the page should be preserved after the postback.

Second, you basically have 2 choices with ASP.NET AJAX to run server side code asychronously. It depends on how you want the page on the client to behave after the server side code executes.

Choice A: Using ASP.NET UpdatePanel
This is a good choice if the UI has to be updated after the AJAX call. You can just wrap any UI controls that need to be updated inside the UpdatePanel control. Note that this will run through the normal page life cycle on the server side and any controls inside the UpdatePanel will be updated on the client. This is very similar to a regular postback except only parts of the page is updated on the clientside.

Choice B: Using webservice or page methods
This is a good choice if there is minimum updates to the UI after the AJAX call and your server side code does not rely heavily on the current state of the UI. You mention you are doing an update to the database. You can probably create a webservice method or a static page method that does the update, given some parameters. Then you just wire up your ext button client click function to hit that webservice/page method and NOT do a postback. If you need the UI to change after the call, you will have to do it manually on the clientside.

Lots of good info on ASP.NET Ajax on www.asp.net/ajax and msdn.

Jul 01, 2008, 5:47 PM

posting your code will make helping you easier. :)