How to programatically set scrollbar position for treeview

Posted on 2007-10-01
Last Modified: 2008-03-01

I am using an ASP.Net 2.0 treeview. A node in the treevieview is being expanded programatically using the node.expand() method. This all works, however, currently I have to scroll down to see the expanded node. My question is, how can I programatically have the scrollbar position itself to show the expanded node.

myNode1 = New TreeNode()
                myNode1 = tvSMQs.FindNode("myRootNode/version7/1002/4586")

Question by:MAIGUI
    LVL 27

    Accepted Solution

    Not sure if this would help or not but its worth a shot
    try placing MaintainScrollPositionOnPostback="true" in your aspx page directive
    if that doesnt work try the script posted on here

    Author Comment

    Hello sammy1971,

    Thank you for your reply. Unfortunatly, MaintainScrollPosition will not work for me since, I am expanding the node programatically.

    Here is  how the app is working, page loads (therefore scroll position is at the top of the page), then I programatically call the expand method of a node toward the bottom of the page. MaintainScrollPosition would maintain the previous scroll position at the top of the page.

    What I need through is a way to move the scroll position to the expanded node.

    LVL 27

    Expert Comment

    You should read the link I posted
    it has a clientscript which should work for you
    The script posted by the_lorax

    Author Comment

    I will try that out. Can you tell me how I can get the client id of a given tree node though? I will need to get this and pass it to the client script in order to try it out. Thanks
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now