How to check Updatepanel asynch postback

Last post 09-26-2008 3:15 AM by Pawan_Mishra. 3 replies.

Sort Posts:

  • How to check Updatepanel asynch postback

    09-26-2008, 12:21 AM
    • Member
      5 point Member
    • David1234
    • Member since 09-26-2008, 4:15 AM
    • Posts 4

     

    Hi,

       How to check whether postback is happening due to control inside updatepanel, so to avoic that code execution during postback

      is it possible?

     thanks 

     

  • Re: How to check Updatepanel asynch postback

    09-26-2008, 2:03 AM
    Answer
    • Participant
      1,285 point Participant
    • ajaykhedekar
    • Member since 08-19-2008, 9:55 AM
    • Mumbai,India
    • Posts 155

     

    HI,

    You can use use ScriptManager.IsInAsyncPostback

    for more detials checkout following link

     http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.isinasyncpostback.aspx

    Happy Coding,

    Ajay
  • Re: How to check Updatepanel asynch postback

    09-26-2008, 3:11 AM
    • Star
      8,753 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 1,279

    Hi ,

    You can cancel the asyncpostback request in client side itself and for this check out this link :- http://www.dotnetcurry.com/ShowArticle.aspx?ID=176 .

    The following code is taken from the same link which I have mentioned above :-

    function pageLoad()
            {       
                Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(cancelPostBack);
            }
           
            function cancelPostBack(sender, args)
            {
                if (Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack())        
                {
                    alert('One postback at a time please');
                    args.set_cancel(true);
                }
            }
     
     Now in the cancelPostBack method you have args parameter . In order to know which element caused the postback you can use the following code snippet :-
                    var postBackElement = args.get_postBackElement();
    So once you know which element caused the postback you can abort the postback . For more on this :- http://www.codeproject.com/KB/ajax/AjaxClientPageLifeCycle2.aspx?display=Print
    Regards
    Pawan Mishra

    Moving from Asp.Net to WPF and SilverLight .....

    .Net 360°
  • Re: How to check Updatepanel asynch postback

    09-26-2008, 3:15 AM
    • Star
      8,753 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 1,279
    Regards
    Pawan Mishra

    Moving from Asp.Net to WPF and SilverLight .....

    .Net 360°
Page 1 of 1 (4 items)