Maintain position in treeview?

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.
 
M

Magnusb

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.
 
M

Magnusb

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top