Last post Nov 26, 2009 01:18 PM by mohi
Jul 23, 2006 10:14 PM|pmccoy|LINK
Thanks to anyone that can help me with this. Before laying out the problem I'm having, I should mention that my project is a web part designed for a Sharepoint Portal. From what I can tell, that limits me to a non-visual implementation of the treeview
and forces me to do everything in a sort of a "code behind" page.
With that said, I have been able to successfully implement the treeview into a web part and it works quite well. The issue I'm having is that the code that generates my tree takes a little while to run and I'd like to minimize the number of postbacks.
More specifically, I would like to limit postbacks to "selectedindexchanged" events only. The problem is that this control appears to be "all or nothing" in terms of events. In other words, if I set autopostback to "false", I can't get the selectedindexchanged
event to fire. If I set autopostback to "true", I get a postback on node expand and collapse events as well as the index changed event.
So, the question is... can I:
- somehow manually force a postback for the selectedinexchanged event when the autopostback is set to "false" or...
- somehow disable the postback for the expand/collapse events when the autopostback is set to "true"?
Jul 24, 2006 09:42 AM|pmccoy|LINK
Aug 01, 2006 12:37 AM|vishalDotNet|LINK
hi brother ,
i am also facing the same issue , could you please help me to come out of it or gimme the link of he post that solved your issue.
Aug 01, 2006 08:46 AM|pmccoy|LINK
This link has several solutions: http://forums.asp.net/thread/469254.aspx
The best one I found was offered by persky. To use it, backup the treeview.htc file and then open it with notepad or some other text editor. Find the function "nodePlusMinusClick" and replace the entire function with the following code:
if (g_bInteractive == false)
var el = this.parentElement.treenode;
// 2 lines below commented out to disable postback on expand/collapse, extra lines added below for better functionality
// if (doNodePlusMinusClick(el) == true)
var index = getNodeIndex(el);
// if the selected or hovered node was one of the collapsed node's descendants then postback anyway
if (selectedNodeIndex.length > index.length && selectedNodeIndex.substr(0,index.length) == index)
if (doNodePlusMinusClick(el) == true)
// otherwise just do the expand/collapse stuff
Nov 01, 2007 09:22 AM|ashwn_acharya|LINK
You can disable postbacks for expand/collapse events by Setting the property TreeNode.SelectAction = TreeNodeSelectAction.Expand. This will cause the treenodes to expand/collapse without a postback. If you want to enable postback for a particular node,
set the property TreeNode.SelectAction = TreeNodeSelectAction.Select or TreeNodeSelectAction.SelectExpand.
I hope this solves your problem. Cheers!!!
Nov 26, 2009 01:18 PM|mohi|LINK
thanks that worked