<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ScrollPosition.aspx.cs" Inherits="ScrollPosition" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </asp:ScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        window.onscroll = saveScroll;
        var scrollTop = 0;
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

        function EndRequestHandler(sender, args) {
            setScroll();
        }
        function setScroll() {
            window.scrollTo(0, scrollTop);
        }
        function saveScroll() {
            if ($telerik.isSafari && $find("<%= RadAjaxManager1.ClientID %>")._isRequestInProgress) {
                scrollTop = document.body.scrollTop;
            }
            if(!$telerik.isSafari) {
                scrollTop = document.documentElement.scrollTop;
            }
        }
    </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="Panel2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div id="scrollDiv">
    <asp:Panel ID="Panel1" runat="server" Width="300px" Height="300px" BorderStyle="Solid"
        BorderColor="Red" BorderWidth="2px">
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </asp:Panel>
    <asp:Panel ID="Panel2" runat="server" Width="300px" Height="300px" BorderStyle="Solid"
        BorderColor="Blue" BorderWidth="2px">
        <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    </asp:Panel>
    </div>
    </form>
</body>
</html>
