I am using VS 2005 treeview control.
How can I set focus to and scroll into view the node clicked when the page
posts back.
My treeview has many nodes and continues way beyond the bottom of the page
when expanded (scroll bar shows). When I scroll to a node and click on it the
postback occurs. When the page shows again the tree view has scrolled back so
the first node is at the top of the page and the clicked node is now out of
view.
I solve this problem in the HTML table by using the scrollIntoView of a
element in javascript. Is there a method in the treeview to do this.
Hi Jerry,
Welcome to the MSDN newsgroup.
From your description, I understand you have an ASP.NET 2.0 web page which
contains a TreeView with large number of TreeNodes. And since the large
TreeView will make the page display scrollbar, you're wondering how to
gracefully keep the page scrolling to the current selected TreeNode across
multiple postbacks, correct?
Based on my research, as for the scroll position, ASP.NET 2.0 TreeView
control doesn't provide any built-in methods or setting to help maintain
the scroll postion of the current selected TreeNode. However, the ASP.NET
2.0 page does provide a setting for keeping the page's current scroll
position across multiple postbacks and this is a page wide setting rather
than specific to TreeView.
#Page.MaintainScrollPositionOnPostBack Property
http://msdn2.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpo
sitiononpostback.aspx
Generally, we configure this setting through the @Page directive, e.g.
<%@ Page Language="C#" ......................
MaintainScrollPositionOnPostback="true"%>
BTW, as for the original html/script approach you mentioned:
=================
I solve this problem in the HTML table by using the scrollIntoView of a
element in javascript. Is there a method in the treeview to do this.
=================
This is a good solution for general scenario when we can get the certain
control's client-side html element(through ID..). However, for TreeView,
its TreeNodes are not simply a certain html element(is composited by many
html elements) and there is no direct association between its Node name and
client-side html element, it's hard to utilize the "ScrollIntoview"
approach.
Just some of my understanding and suggestion, hope this helps. If you have
any other idea or consideration, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Signature
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven Cheng[MSFT] - 31 May 2006 13:13 GMT
Hello Jerry,
How are you doing on this issue, have you got any further process or does
the suggestion in my last reply helps you a little? If there is anything
else we can help, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Signature
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)