Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9110261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:13:44+00:00 2026-06-17T03:13:44+00:00

I have a user control that has a treeview in it. Every time the

  • 0

I have a user control that has a treeview in it. Every time the user expands a node, it gets reloaded using an update panel. To prevent the user having to scroll through the treeview everytime it reloads, I want to capture the current div’s scrollTop value, save it to a textbox and then after post back, take that value and reload it. Everything works except one odd behavior. This is the div:

<div ID="treePanel" runat="server"  class="treePanel"  onscroll="setScroll(this.scrollTop)" onunload="testScroll()" >
<asp:TextBox ID="scrollTb" runat="server" Text="" ></asp:TextBox>
<asp:TreeView ID="TreeView1" runat="server"  
OnTreeNodeExpanded="Node_Expand" CollapseImageToolTip="Click To Collapse" ExpandImageToolTip="Click To Expand">                     
</asp:TreeView> 
</div>

and this is the javascript functions, which is in the masterpage:

function setScroll(getVal){               
var getTb = document.getElementById("ctl00_ContentPlaceHolder1_rmsStepThree1_scrollTb")            
getTb.value= getVal
}

function testScroll(){
var getTb = document.getElementById("ctl00_ContentPlaceHolder1_rmsStepThree1_scrollTb")         
var getDiv = document.getElementById("ctl00_ContentPlaceHolder1_rmsStepThree1_treePanel")         
getDiv.scrollTop= getTb.value
}

The problem is that this wont work unless i add an “Alert()” in the javascript, like this:

function testScroll(){
var getTb = document.getElementById("ctl00_ContentPlaceHolder1_rmsStepThree1_scrollTb")         
var getDiv = document.getElementById("ctl00_ContentPlaceHolder1_rmsStepThree1_treePanel")  
alert('some text')       
getDiv.scrollTop= getTb.value
}

Can anyone explain why this is behaving this way and how to remedy it? I obviously can’t have the alert in there.

thanks
jason

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:13:45+00:00Added an answer on June 17, 2026 at 3:13 am

    Alerts fixing code normally means a race condition is in place. You are calling the code before the div is rendered fully. The alert is allowing it to be rendered fully. Shouldn;t you be setting the scroll position after the new content is loaded, not when it is unloaded?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that has a few public properties, one is an
I have an abstract user control(baseModule) that has a property that I plan on
I have a user control that contains a GridView. The GridView has both a
I have an User Control that host another controls like panel, chart controls. Right
I have a user control that has label and text box but i can't
I have a user control that has a textbox. I have tried to expose
I have a User Control that has some WinForm Controls inside. I want to
I have a user control that has a text box and a button. I
I have a user control that has a Title property bound to the Text
I have a user control that inside has a TextBlock (textmsg), the following is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.