Maintain position in treeview?

  • Thread starter Thread starter Magnusb
  • Start date Start date
M

Magnusb

I have a web page with a Treeview. Problem is when you for example
expand a node and the page is refreshed the position in the treeview
returns to top, which means you have to scroll the treeview to get back
to your previous position. What I want is the treeview to maintain the
position in the treeview.

I have tried to inject (from code behind) a Javascript which does
something like this: (I am actually usign something like in this
article:
http://www.codeguru.com/csharp/.net/net_asp/scripting/article.php/c12869
)

<script>
function LoadEvent()
{
try
{
var elem = document.getElementById('TreeView1_SelectedNode');
if(elem != null )
{
var node = document.getElementById(elem.value);
if(node != null)
{
node.scrollIntoView(true);
Panel1.scrollLeft = 0;
}
}
}
catch(oException)
{}
}// -->
</script>


But it is still not working. I am not sure if there is something else
which affect the execution (for example something that is executed after
my javascript has run).

I am using a master/content page where my treeview is in the content
page. The treeview control i sembeed in a user control.
 
It is most certainly something that get executed after my javascript
code which loose position in treeview. When I load the page I see that
node.ScrollIntoView get executed and postion move to that node in
treeview and after it reset and position is moved to top of tree view.

Any ideas why? Any properties that might affect this?

How can I make sure that my onload is run after all other scrips have
been run (or using any other event). Might be some automatically server
generated client script that runs after my script causing problems.
 
How can I make sure that my onload is run after all other scrips have
been run (or using any other event). Might be some automatically server
generated client script that runs after my script causing problems.

For anyone lurking having the same problem. I solved this by using
Sys.Application.add_load to add my script and that worked fine. Seems
there are some AJAX scrips executing after window.onload.
 
Back
Top