1
Answer

maintain scrollbar position

Ask a question
scampercat

scampercat

12y
1.7k
1
In a C# 2010 web form application, I want to maintain the scroll bar position in Panel1 listeb below. According to the following
link: http://gnidesign.blogspot.com/2011/06/how-to-maintain-page-scroll-on-postback.html, the javascript code that I supplied below
should work. My problem is there is not a 'head' html tag for me to embed the javascript code into.

  Thus can you tell me what is wrong with the Javascript code I have below? Do I have the code in the wrong postion of the *.aspx
page?
   Can you tell me how to maintain the scrollbar position of panel1?

   Here is the code I am referring to:
<%@ Page Title="" Language="C#" MasterPageFile="~/App.Master" AutoEventWireup="true" MaintainScrollPositionOnPostback="true"
    CodeBehind="Atts.aspx.cs" Inherits="RpcSupport.Atts" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="TopMenu" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ReportForm" runat="server">
   <ajx:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true">
    </ajx:ToolkitScriptManager>
    <asp:UpdatePanel ID="AttUploadUpdatePanel" runat="server">
        <ContentTemplate> 
            <table style="width: 100%;">
                <tr>
                    <td>
                        <table style="width: 50%;">
                            <tr>
                                <td width="100px" rowspan="5">
                                </td>
                            </tr>
                        </table>
                    </td>
                    <asp:Table ID="uploadAtttb" runat="server" Height="35px" HorizontalAlign="Center"
                        Width="50%">
                        <asp:TableRow ID="trTitle" runat="server" HorizontalAlign="Center">
                            <asp:TableCell ID="TableCell1" runat="server" RowSpan="1" ColumnSpan="5" VerticalAlign="Top" HorizontalAlign="Center">
                                <asp:Label ID="Label1" runat="server" CssClass="RptPageTitle" Text="Att Entry" />
                            </asp:TableCell></asp:TableRow><asp:TableRow ID="TableRow1" runat="server">
                            <asp:TableCell ID="TableCell2" runat="server" RowSpan="1" ColumnSpan="5" VerticalAlign="Top" HorizontalAlign="Center">
                                <asp:Label ID="lblResultMsg" runat="server" CssClass="msgStyle" />
                                <asp:Label ID="lblErrorMsg" runat="server" CssClass="errorStyle" />
                            </asp:TableCell></asp:TableRow><asp:TableRow ID="TableRow2" runat="server">
                            <asp:TableCell ID="TableCell3" runat="server" HorizontalAlign="Right">
                                <asp:Label ID="Lable2" runat="server" Text="Org Name" CssClass="RptFormLabel" />
                            </asp:TableCell><asp:TableCell ID="TableCell4" runat="server" HorizontalAlign="Left" AutoPostBack="true">
                                <asp:TextBox ID="txtOrgID" Visible="false" Enabled="true" runat="server" Width="100"
                                    MaxLength="10" />
                                <asp:TextBox ID="txtOrgName" runat="server" Width="250" CssClass="TextBoxStyle" OnTextChanged="FindOrg"
                                    AutoPostBack="true" MaxLength="100" />&nbsp;
                            <ajx:AutoCompleteExtender ID="AutoCompleteAtt" runat="server" CompletionListCssClass="AjaxListStyle"
                                    TargetControlID="txtOrgName" ServiceMethod="GetOrgAttList" ServicePath="Atts.aspx"
                                    MinimumPrefixLength="1" CompletionInterval="200" CompletionSetCount="50">
                                </ajx:AutoCompleteExtender>  
                            </asp:TableCell></asp:TableRow><asp:TableRow ID="TableRowa" runat="server" Visible="true">
                        </asp:TableRow>
                        <asp:TableRow ID="TableRowb" runat="server" Visible="true">
                            <asp:TableCell ID="TableCell5" runat="server" HorizontalAlign="right">
                            </asp:TableCell><asp:TableCell ID="TableCell5a" runat="server" HorizontalAlign="left">
                                <asp:Panel ID="Panel2" runat="server" CssClass="TextBoxStyle" GroupingText="Compoany Number and Name">
                                    <asp:Panel ID="Panel1" runat="server" ScrollBars="Auto" Height="130px" Width="455"
                                        CssClass="TextBoxStyle">
                                        <asp:CheckBoxList ID="ChkBoxLstPlan" runat="server" >
                                        </asp:CheckBoxList>
                                    </asp:Panel>
                                </asp:Panel>
                           
                               <div>
                                    <asp:RequiredFieldValidator CssClass="errorStyle" ID="reqVal1" Display="Dynamic"
                                        runat="server" ControlToValidate="txtOrgName" ErrorMessage="'Organization Name' is a required field." />
                                </div>
                               
                            </asp:TableCell></asp:TableRow></asp:Table></tr></table></ContentTemplate>
                       </asp:UpdatePanel></asp:Content><asp:Content ID="Content5" ContentPlaceHolderID="ReportBody" runat="server">
<script type="text/javascript">
    window.scrollTo = function () { }
</script>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Footer" runat="server">
</asp:Content>

Answers (1)