Thursday, May 27, 2010

My Experience with document.getElementById()

Hello friends,

I would like to share one interesting experience with you.

Currently, I was working with Asp.Net tree view. The data in tree view is very large, so we implemented search functionality in tree view. User can add text of a node to be searched. If more than one node found, each node will be checked in tree view. As I have mentioned the data in a tree is very large, so we have kept this tree inside a panel so that user can scroll up or down to view entire tree view.

Then one more client requirement came. When a node found during a search, panel should be scrolled down to location of that particular node in tree view. For that we have used document.getElementById('TreeView1_SelectedNode') to get selected node. Then using its location. we have scrolled panel.

Here comes interesting part. What if I have more than one selected node. I was under the impression that it should return first selected node and ignore the rest. However, I was surprised that it returns me last selected node and panel scrolled down to last selected node.

No comments:

Post a Comment