/    Sign up×
Community /Pin to ProfileBookmark

How to keep scrollbar position while Timer is updating UpdatePanel?

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

[CODE]<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>[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @dejanc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...