ext:button and AJAX

  1. #1

    ext:button and AJAX

    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
    Tony




  2. #2

    RE: ext:button and AJAX

    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.
  3. #3

    RE: ext:button and AJAX



    t0ny,


    posting your code will make helping you easier. :)

Similar Threads

  1. Replies: 2
    Last Post: Jul 15, 2010, 8:36 PM
  2. Replies: 1
    Last Post: Jun 09, 2010, 11:47 PM
  3. [CLOSED] Button with ajax menu using WebServices
    By pil0t in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 05, 2010, 11:35 AM
  4. [CLOSED] Interrupting a button ajax click event.
    By Riset in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 20, 2009, 3:24 PM
  5. [CLOSED] ext button ajax event not updating a repeater
    By WP in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 02, 2008, 11:39 AM

Posting Permissions