Disabling treeview eventshttp://forums.asp.net/t/1010828.aspx/1?Disabling+treeview+eventsThu, 26 Nov 2009 17:18:32 -050010108281349207http://forums.asp.net/p/1010828/1349207.aspx/1?Disabling+treeview+eventsDisabling treeview events <p>Thanks to anyone that can help me with this.&nbsp; Before laying out the problem I'm having, I should mention that my project is a web part designed for a Sharepoint Portal.&nbsp; 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 &quot;code behind&quot; page.</p> <p>With that said, I have been able to successfully implement the treeview into a web part and it works quite well.&nbsp; 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.&nbsp; More specifically, I would like to limit postbacks to &quot;selectedindexchanged&quot; events only.&nbsp; The problem is that this control appears to be &quot;all or nothing&quot; in terms of events.&nbsp; In other words, if I&nbsp;set autopostback to &quot;false&quot;, I can't get the selectedindexchanged event to fire.&nbsp; If I set autopostback to &quot;true&quot;, I get a postback on node expand and collapse events as well as the index changed event.</p> <p>So, the question is... can I:</p> <p>- somehow manually force a postback&nbsp;for the selectedinexchanged event when the autopostback is set to &quot;false&quot; or...</p> <p>-&nbsp;somehow disable the postback for the expand/collapse events when the autopostback is set to &quot;true&quot;?</p> <p>- Pete</p> 2006-07-24T02:14:24-04:001349600http://forums.asp.net/p/1010828/1349600.aspx/1?Re+Disabling+treeview+eventsRe: Disabling treeview events Never mind... I found a post about how to do this by modifying the htc files.&nbsp; Thanks to those that have posted the htc file modifications! 2006-07-24T13:42:12-04:001356901http://forums.asp.net/p/1010828/1356901.aspx/1?Re+Disabling+treeview+eventsRe: Disabling treeview events <p>hi brother ,</p> <p>&nbsp;</p> <p>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.</p> 2006-08-01T04:37:09-04:001357204http://forums.asp.net/p/1010828/1357204.aspx/1?Re+Disabling+treeview+eventsRe: Disabling treeview events <p>This link has several solutions: <a href="/thread/469254.aspx">http://forums.asp.net/thread/469254.aspx</a></p> <p>The best one I found was offered by persky.&nbsp; To use it, backup the treeview.htc file and then open it with notepad or some other text editor.&nbsp; Find the function &quot;nodePlusMinusClick&quot; and replace the entire function with the following code:&nbsp;</p> <pre class="prettyprint">function nodePlusMinusClick() { if (g_bInteractive == false) return; 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) // fireQueuedEvents(); var index = getNodeIndex(el); // if the selected or hovered node was one of the collapsed node's descendants then postback anyway if (selectedNodeIndex.length &gt; index.length &amp;&amp; selectedNodeIndex.substr(0,index.length) == index) { if (doNodePlusMinusClick(el) == true) fireQueuedEvents(); } // otherwise just do the expand/collapse stuff else doNodePlusMinusClick(el); }</pre>&nbsp; 2006-08-01T12:46:01-04:001985025http://forums.asp.net/p/1010828/1985025.aspx/1?Re+Disabling+treeview+eventsRe: Disabling treeview events <p>Hi,</p> <p>&nbsp;&nbsp;&nbsp; You can disable postbacks&nbsp; 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. </p> <p>I hope this solves your problem. Cheers!!!&nbsp;</p> 2007-11-01T13:22:26-04:003534834http://forums.asp.net/p/1010828/3534834.aspx/1?Re+Disabling+treeview+eventsRe: Disabling treeview events <p>thanks that worked</p> 2009-11-26T17:18:32-05:00