Scroll bar not maintaining its position in ListView (ASP.net)
-
Hi I have a listview inside a DIV which shows the scroll bars. At one time, let's say, 10 rows can be seen. I scroll down and click Edit on 25 row. To my surprise, the scroll goes to the first row (although if I go back to 25th row, the row is in edit mode) My issue, how I can make sure that the scroll bar maintains its position to 25th row after clicking on Edit button? Please advise. Thanks AJ
<style>
.StopScroll1{
Z-INDEX: 20; POSITION: relative;left:-1px; TOP: expression(document.getElementById("divGrid1").scrollTop);
}
</style><div id="div1" style="position: relative; width: 100%; width: 700px; height: 200px;
margin: 0px; padding: 0px; overflow: auto; overflow-x: scroll; overflow-y: scroll">
<asp:ListView ID="ListView1" runat="server
OnSorting="Sorting"
OnItemEditing=" EditList"
>
<LayoutTemplate>
<table class="TableReleative TableFH" style="width: 97.5%;" cellspacing="0" cellpadding="0"
runat="server" id="tblGrid">
<tr style="height: 20px;" class="StopScrollTL" runat="server" id="thGrid">
<th style="text-align: center;">
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
.....
</ItemTemplate><EditItemTemplate> ..... </EditItemTemplate> </asp:ListView>
</div>
Follow your goals, Means will follow you ---Gandhi---
-
Hi I have a listview inside a DIV which shows the scroll bars. At one time, let's say, 10 rows can be seen. I scroll down and click Edit on 25 row. To my surprise, the scroll goes to the first row (although if I go back to 25th row, the row is in edit mode) My issue, how I can make sure that the scroll bar maintains its position to 25th row after clicking on Edit button? Please advise. Thanks AJ
<style>
.StopScroll1{
Z-INDEX: 20; POSITION: relative;left:-1px; TOP: expression(document.getElementById("divGrid1").scrollTop);
}
</style><div id="div1" style="position: relative; width: 100%; width: 700px; height: 200px;
margin: 0px; padding: 0px; overflow: auto; overflow-x: scroll; overflow-y: scroll">
<asp:ListView ID="ListView1" runat="server
OnSorting="Sorting"
OnItemEditing=" EditList"
>
<LayoutTemplate>
<table class="TableReleative TableFH" style="width: 97.5%;" cellspacing="0" cellpadding="0"
runat="server" id="tblGrid">
<tr style="height: 20px;" class="StopScrollTL" runat="server" id="thGrid">
<th style="text-align: center;">
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
.....
</ItemTemplate><EditItemTemplate> ..... </EditItemTemplate> </asp:ListView>
</div>
Follow your goals, Means will follow you ---Gandhi---
Looks like you page gets a postback when you click the edit link. If so, try to set the
Page.MaintainScrollPositionOnPostBack
Property to true to return the user to the same position in the client browser after postback. (i.e. enabling smart navigation, see if it works!) If not, you will have to use javascripts in order to restore the scrolls. For that, before postback, you need to store the scroll position in a variable and then after page reloads, set it back.