Udostępnij za pośrednictwem


Resolution: Problems with Ajax development/ Page does post back

If the you have applied bluband.master then we need to do changes in bluband.master per the solution step [2]

[1]
Webpart change
Add following code in your webpart and call it in CreateChildControls

//in CreateChildControls method
//Fix for the UpdatePanel postback behaviour.
            EnsurePanelFix();

private void EnsurePanelFix()
        {
            if (this.Page.Form != null)
            {
                String fixupScript = @"
                                         _spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");
                                         function _initFormActionAjax()
                                         {
                                           if (_spEscapedFormAction == document.forms[0].action)
                                           {
                                             document.forms[0]._initialAction =
                                             document.forms[0].action;
                                           }
                                         }
                                         var RestoreToOriginalFormActionCore =
                                           RestoreToOriginalFormAction;
                                         RestoreToOriginalFormAction = function()
                                         {
                                           if (_spOriginalFormAction != null)
                                           {
                                             RestoreToOriginalFormActionCore();
                                             document.forms[0]._initialAction =
                                             document.forms[0].action;
                                           }
                                         }";
                ScriptManager.RegisterStartupScript(this,
                  typeof(TjWP), "UpdatePanelFixup",
                  fixupScript, true);
            }
        }

[2]
blueband.master change

<body class="body" onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">
<form runat="server" onsubmit="return _spFormOnSubmitWrapper();">
<WebPartPages:SPWebPartManager runat="server"/>
<asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>

 

Keywords

Postback happens for AJAX enabled Web part, SharePoint, Ajax, blueband.master, Publishing site template