Search code examples
c#asp.netajaxmicrosoft-ajax

How do i get the parameter passed in _dopostback() in endrequest method?


How to I get the parameter value passed in

_dopostback('','');

For Example
__doPostBack('<%=upSubAccount.ClientID %>',true);
I want to get the second parameter in endrequest() handler, here

//wire the End Request process,

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(requestComplete_Handler)

    //will be called after the async request completes.
    function requestComplete_Handler(sender, args)
    {
        var panel = sender._postBackSettings.sourceElement.id;
        switch (panel)
        {
            case "<%=upSubAccount.ClientID %>":
                __doPostBack('<%=upAllocationChart.ClientID %>');
                break;
        }
    }

Solution

  • The second argument is the event argument.
    It is not stored by the framework.
    However you can easily store it in a variable of your own and access it later.
    You only need to replace the __doPostBack with your own function.

    var orignalDoPostback = __doPostBack;
    var lastEventArgument = "";
    __doPostBack = function(eventTarget, eventArgument)
    {
       lastEventArgument = eventArgument;
       orignalDoPostback(eventTarget, eventArgument);
    }
    

    Then you can use it as required.