Saturday, April 23, 2016

Maintain Panel/Div Scroll Position in UpdatePanel On Postback ASP.NET


  <form id="form1" runat="server">  
  <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release" />  
   <script type="text/javascript">  
     // It is important to place this JavaScript code after Ajax ScriptManager / Toolkit Script  
     var xPos, yPos;  
     var prm = Sys.WebForms.PageRequestManager.getInstance();  
     function BeginRequestHandler(sender, args) {  
       if ($get('<%=Panel1.ClientID%>') != null) {  
        // Get X and Y positions of scrollbar before the partial postback  
        xPos = $get('<%=Panel1.ClientID%>').scrollLeft;  
       yPos = $get('<%=Panel1.ClientID%>').scrollTop;  
     }  
   }  
   function EndRequestHandler(sender, args) {  
     if ($get('<%=Panel1.ClientID%>') != null) {  
        // Set X and Y positions back to the scrollbar  
        // after partial postback  
        $get('<%=Panel1.ClientID%>').scrollLeft = xPos;  
        $get('<%=Panel1.ClientID%>').scrollTop = yPos;  
      }  
    }  
    prm.add_beginRequest(BeginRequestHandler);  
    prm.add_endRequest(EndRequestHandler);  
  </script>  
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
   <ContentTemplate>  
    <asp:Panel ID="Panel1" runat="server" Height="300px">  
     <%--Data--%>  
    </asp:Panel>  
   </ContentTemplate>  
  </asp:UpdatePanel>  
 </form>  

Tuesday, April 19, 2016

[Solved] Ajax async postback end does not work Script Error : Uncaught Sys.ScriptLoadFailedException: Sys.ScriptLoadFailedException: The script failed to load. Check for: Inaccessible path. Script errors. (IE) Enable 'Display a notification about every script error' under advanced settings. Missing call to Sys.Application.notifyScriptLoaded().

Solution For ajax async postback end does not work


 <script type="text/javascript">  
      function pageLoad(sender, args) {  
        //$(document).ready(function () {  
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);  
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);  
        Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit  
        if (navigator.userAgent.indexOf('WebKit/') > -1) {  
          Sys.Browser.agent = Sys.Browser.WebKit;  
          Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);  
          Sys.Browser.name = 'WebKit';  
        }  
        var xPos, yPos;  
        function beginReq(sender, args) {  
          //  $find(ModalPopup).show();  
        }  
        function endReq(sender, args) {  
          //  $find(ModalPopup).hide();  
        }  
        //});  
      }  
 </script>  

Use this script inside the page. :)