Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
confirming action on toolbar clientsideevent and asynchronous callbacks
posted

I have a toolbar and a webgrid inside a WebAsyncRefreshPanel (WARP). My toolbar has a "delete" button, if pressed it should prompt to confirm the action. If cancelled, nothing should happend, and if confirmed the selected row should be deleted. The WARP has it's TriggerControlIDs property setted with the delete button client ID.

I programmed the client side event to prompt for confirmation and it's working fine, when canceled no postback occurs, but if confirmed it generates a regular postback in stead of an asynchronous postbak. If I remove the client side event, then the postback is triggered asynchronous. What could be happening?

Some more information: wether the postback is asynchronous or not depends of if I'm showing or not a javascript alert or or confirm window. Here is my code:

function Barra_ClientSideEvent_Click(oToolBar, oItem, oEvent) {

if (oItem.Key.toUpperCase().indexOf('DELETE') >= 0)

    if (!confirm("Confirm operation?"))

        oEvent.needPostBack = false;

}

If I comment out the "confirm", the postback is asynchronous, but If I leave it there the postback is full page.

Is there something I can do about this?

 

Thanks in advance

Parents
No Data
Reply
  • 24497
    posted

    Hi,

    To identify trigger of its async postback the CallBackManager (warp), uses various form events like mousedown/click/etc. which potentially can trigger submit and if submit happened, then it tries identify if last browser event happened for a its child control or its trigger. For that purpose the time difference is used (for example between last click and submit). If time difference is small, then CallBackManager assumes that submit belongs to it. In this case it cancels default submit behavior of browser and triggers its own async postback.

    So, if between click and submit is long delay, like alert or confirm, then CallBackManager is not able to identify trigger and async postback does not happen.

    I suggest you instead of changing value of oEvent.needPostBack, use explicit async postback for a warp. To trigger that you may call call

    __doPostBack(idOfAnyHtmlElementLocatedInWARP, '');

    or call

    referenceToWarp.refresh();

Children
No Data