Weird bug when combining an ASP.NET updatepanel with the jQuery UI DatePicker

前端 未结 10 757
时光说笑
时光说笑 2021-02-04 15:42

I\'ve created a page which combines an inline jQuery UI datepicker . I wan\'t to initiate a callback to the updatepanel when the user clicks a new date to update some data. Now,

相关标签:
10条回答
  • 2021-02-04 16:12

    I have fixed various async issues with jQuery/Updatepanels using the ScriptMode="Release" argument on the ScriptManager.

      <asp:ScriptManager ID="scriptManager" runat="server" ScriptMode="Release">
      </asp:ScriptManager>
    
    0 讨论(0)
  • 2021-02-04 16:14

    I liked Tim's answer, surrounding the idea that you should be using args.get_PanelsUpdated() in the pageLoaded event. It seems like the appropriate means for doing what you're attempting to do. Try it out -- if it doesn't work, then I've got another idea up my sleeve (though its kind of dirty).

    0 讨论(0)
  • 2021-02-04 16:14

    I thought this was interesting, if you add an alert after the doPostBack then FF doesn't return null.

        function doAspNetPostback() {
    
            __doPostBack('<%= hiddenOnSelectionChangedButton.ClientID %>', '');
            alert('<%= hiddenOnSelectionChangedButton.ClientID %>');
        }
    
    0 讨论(0)
  • 2021-02-04 16:19

    I think you my find this article from MSDN interesting: http://msdn.microsoft.com/en-us/magazine/cc163413.aspx

    The article says that "Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(" also attaches to Updatepanel complete events.

    It also fires each time an asynchronous callback launched on behalf of an UpdatePanel control completes and the content inside that UpdatePanel is updated.

    then in your handler you can loop through the updatedpanels with

    var panels = args.get_panelsUpdated();
    for (i=0; i < panels.length; i++) { alert(panels[i]); }
    

    I would stray away from using the _ postBackSettings because of the " _ " denotes privacy and may be discontinued in future versions of asp.net ajax.

    0 讨论(0)
  • 2021-02-04 16:21

    However, if I step through the code in FireBug slow enough it works

    Oh? Why not give it a second to work it out?

    setTimeout(function(){alert(sender._postBackSettings.panelID);},1000);
    
    0 讨论(0)
  • 2021-02-04 16:32

    I found another script a while back that I've been using for a while now and have never had any problems with.

     <script type="text/javascript">
            /*
            [__doPostBackAsync]
            Will send an async postback to the backend
            */
            function __doPostBackAsync(eventName, eventArgs) {
                var prm = Sys.WebForms.PageRequestManager.getInstance();
    
                //check first if the request queues have this item
                if (!Array.contains(prm._asyncPostBackControlIDs, eventName)) {
                    prm._asyncPostBackControlIDs.push(eventName);
                }
                if (!Array.contains(prm._asyncPostBackControlClientIDs, eventName)) {
                    prm._asyncPostBackControlClientIDs.push(eventName);
                }
                __doPostBack(eventName, eventArgs);
            }
        </script>
    

    You can still manually set a callback function exactly like you do in your above script.

    You may also have to manually add a scriptresource handler (Can't remember which one) but I specifically remember having problems calling async and non-async post backs. Hope that helps.

    0 讨论(0)
提交回复
热议问题