Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep scrollbar position while Timer is updating UpdatePanel?

Status
Not open for further replies.

DejanDejanovic

Programmer
Feb 15, 2012
1
0
0
SI
Hello,
I need help.
I'm testing aps.net controls. I have add Repeater with some content. Repeater is inside of Panel which has Vertical ScrollBars. Timer1 is updating Repeater. As I need scrollbar on PageLoad on the bottom of Panel control, I have add javascript.
But, now problem is each time when try to move scrollbar up, Timer push it down. But, I would like somehow to keep in position if move it. I have try it with javascript code OnMouseOver with _StopTimer, but it effect only when mouse is over asp.net cotrol, not it's scrollbar.

Any idea? Note: I have been Googling, Yahooing many ours, and try different codes, but none was working. So, really need some new approach.
Note: MaintainScrollPositionOnPostback="true" is already added on page.

Thank you in advance for help.

<asp:ScriptManager ID="ScriptManager1" runat="server"/>
<script type="text/javascript">
if (Sys != null) {
var instance = Sys.WebForms.PageRequestManager.getInstance();

if (instance != null) {
instance.add_endRequest(function (sender, args) {
SetScroll()
});
}
}

function pageLoad() {
window.onload = SetScroll;
}

function SetScroll() {
var objDiv = document.getElementById("<%=Panel1.ClientID%>");
objDiv.scrollTop = objDiv.scrollHeight;
}



</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>

<asp:panel ID="Panel1" runat="server" ScrollBars="Auto" Height="193px"
Width="467px" BorderColor="#66CCFF" BorderStyle="Solid" BorderWidth="1px">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div style="font-family: calibri; color: #000099;">
TEST
</BR>
TEST
</BR>
TEST
</BR>
TEST
</BR>
TEST
</BR>
TEST
</BR>
TEST
</BR>
TEST
</BR>
TEST
</BR>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</asp:panel>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top