How to store multiple scroll positions for scrolling div element depending on active View in MultiView (asp.net webform

Posted by Spence on Stack Overflow See other posts from Stack Overflow or by Spence
Published on 2012-11-21T00:41:56Z Indexed on 2012/11/21 5:00 UTC
Read the original article Hit count: 170

Filed under:
|
|

confusing title but the best way I can put it.

Basically I am currently using a single div with overflow:auto that contains different GridViews. The GridViews are swapped by using a MultiView with each indiviudal view containing a single GridView.

I would like to be able to store the scroll position of each view so that I can set the div's scroll position depending on the view that will be switched to.

Here is how my page is set up.

<div id="scrollingDiv" style="height:100%; overflow:auto;">
  <div id="gridWrap">

  <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline">
  <ContentTemplate>
    <asp:MultiView ID="MultiView1" runat="server">
      <asp:View ID="view1" runat="server">
        <asp:GridView ID="gridView1" runat="server">
        </asp:GridView>
      </asp:View>

      <asp:View ID="view2" runat="server">
        <asp:GridView ID="gridView2" runat="server">
        </asp:GridView>
      </asp:View>
    </asp:Multiview>
  </ContentTemplate>
  </asp:UpdatePanel>

  </div>
</div>

So scrollingDiv will contain all the Views and will scroll for each one of the GridViews.

To switch between views I have a drop down connected to an

protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
    switch (DownList.SelectedItem.Value)
    {

        case "view1":
            MultiView1.SetActiveView(view1);
            break;
        case "view2":
            MultiView1.SetActiveView(view2);
            break;
    }
}

I have been looking around and can't quite find something specific to my case. I would like to be able to use just the one overflow div but would understand if I had to make a separate overflow div for each view.

Any help would be great, Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET