DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 21 Aug 2007 13:13:07 -0400,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Homer J. Simpson
          2    Ladislav Mrnka
                 3    Homer J. Simpson


TreeNode.Value - where can I find it in a client-side script?   
Hi all,

I'm trying to persist the expanded/collapsed state of a TreeView's nodes to 
cookies.  I've managed to accomplish this using OnTreeNodeCollapsed() and 
OnTreeNodeExpanded().  I'm using TreeNode.Value as the name of the cookie, 
and values of either 0 (collapsed) or 1 (expanded) for the cookie's value. 
At any given point later on, I can rely on the cookie's value to determine 
whether I should call TreeNode.Collapse() or TreeNode.Expand() as I'm 
rebuilding the tree.

This works great, but requires a server round-trip.  I'd prefer to avoid 
that if at all possible, especially since the tree's default behavior works 
so nicely and entirely client-side without these two OnTreeNodeXXX() 
overrides.

In my quest to accomplish this, I've stumbled upon the following blog at 
http://daniellarson.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&_c=BlogPart&partqs=amonth%3D5%26ayear%3D2006 
....scrollling down to the bottom, the last entry suggests a somewhat clean 
method to intercept the client-side TreeView_ToggleNode() and inject your 
own code (and still call the expand/collapse client script generated by the 
framework).  The available parameters in the example are named 'data', 
'index', 'node', 'lineType' and 'children'.  It looks like 'children' 
contains the div containing the child nodes, and I may be able to use its 
style.display property to determine whether the current node is expanded or 
collapsed (it'll be set to either 'block' or 'none').

The only thing missing for all these pieces to fall into place is the string 
I assigned (server-side) to TreeNode.Value--I'll be damned if I can find it 
anywhere in these parameters!  I need this for the name of the cookie.

I've tried looking for alternatives to using TreeNode.Value on the client, 
but I can't use the node's unique ID, generated automatically server-side, 
either (eg, "tvnSomething##"), because this name appears to be tied with the 
node's position in the tree--which would be screwy if I start inserting or 
reordering nodes in my tree.  The TreeNode.Value property seems to make the 
most sense.

All this to say:  in my TreeView_ToggleNode() override, where's the value 
mapped to TreeNode.Value?
Date:Tue, 21 Aug 2007 13:13:07 -0400   Author:  

RE: TreeNode.Value - where can I find it in a client-side script?   
Hi,
unfortunatelly, TreeNode.Value is used only if you want to do postback. This 
is common way how the node is renderd (3rd level node) if you don't populate 
NavigateUrl :

<table cellpadding="0" cellspacing="0" style="border-width:0;">
  <tr>
    <td>
      <div style="width:20px;height:1px"></div>
    </td>
    <td>
      <div style="width:20px;height:1px"></div>
    </td>
    <td>
      <img 
src="/TreeView/WebResource.axd?d=ltoyXpSCaVbV2lw9MLsY4MjWwOZEdN72dgmRzP4DJw1&t=632878758459657744" alt="" />
    </td>
    <td style="white-space:nowrap;">
      <a class="myTreeView_0" 
href="javascript:__doPostBack('myTreeView','sroot\\1\\1_3')" 
onclick="TreeView_SelectNode(myTreeView_Data, this,'myTreeViewt5');" 
id="myTreeViewt5">
        ThirdChild
      </a>
    </td>
  </tr>
</table>

As you can see node contains 
href="javascript:__doPostBack('myTreeView','sroot\\1\\1_3')" where 1_3 is 
value of current node, 1 is value of parent node and sroot is value of root 
node.  If you pass any value to navigate url, for example 
http://www.google.com, this postback call will be simple overriden to 
href="http://www.google.com" and you will never get the value. 

Important: Postback with values is used only if node SelectAction is Select 
or SelectExpand.

I hope this will answer your question where you can find node's value.

Regards,
Ladislav

"Homer J. Simpson" wrote:


> Hi all,
> 
> I'm trying to persist the expanded/collapsed state of a TreeView's nodes to 
> cookies.  I've managed to accomplish this using OnTreeNodeCollapsed() and 
> OnTreeNodeExpanded().  I'm using TreeNode.Value as the name of the cookie, 
> and values of either 0 (collapsed) or 1 (expanded) for the cookie's value. 
> At any given point later on, I can rely on the cookie's value to determine 
> whether I should call TreeNode.Collapse() or TreeNode.Expand() as I'm 
> rebuilding the tree.
> 
> This works great, but requires a server round-trip.  I'd prefer to avoid 
> that if at all possible, especially since the tree's default behavior works 
> so nicely and entirely client-side without these two OnTreeNodeXXX() 
> overrides.
> 
> In my quest to accomplish this, I've stumbled upon the following blog at 
> http://daniellarson.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&_c=BlogPart&partqs=amonth%3D5%26ayear%3D2006 
> ....scrollling down to the bottom, the last entry suggests a somewhat clean 
> method to intercept the client-side TreeView_ToggleNode() and inject your 
> own code (and still call the expand/collapse client script generated by the 
> framework).  The available parameters in the example are named 'data', 
> 'index', 'node', 'lineType' and 'children'.  It looks like 'children' 
> contains the div containing the child nodes, and I may be able to use its 
> style.display property to determine whether the current node is expanded or 
> collapsed (it'll be set to either 'block' or 'none').
> 
> The only thing missing for all these pieces to fall into place is the string 
> I assigned (server-side) to TreeNode.Value--I'll be damned if I can find it 
> anywhere in these parameters!  I need this for the name of the cookie.
> 
> I've tried looking for alternatives to using TreeNode.Value on the client, 
> but I can't use the node's unique ID, generated automatically server-side, 
> either (eg, "tvnSomething##"), because this name appears to be tied with the 
> node's position in the tree--which would be screwy if I start inserting or 
> reordering nodes in my tree.  The TreeNode.Value property seems to make the 
> most sense.
> 
> All this to say:  in my TreeView_ToggleNode() override, where's the value 
> mapped to TreeNode.Value? 
> 
> 
> 
Date:Wed, 22 Aug 2007 00:40:00 -0700   Author:  

Re: TreeNode.Value - where can I find it in a client-side script?   

> I hope this will answer your question where you can find node's value.


Yeah, I guess.  Further research was indicating the value wasn't getting 
sent to the browser at all if there weren't any postbacks.

FWIW, I've worked around the problem (to a certain extent) by looking at the 
state of the tree's nodes on Page_Load() instead.  If IsPostBack is true, I 
save the state in cookies at that point and add those cookies to Response. 
The only drawback is that if you switch a node's state and there's no 
further postback after that, you lose *that* change...but I can live with 
that for now, I suppose.

Further details on the design of this--I have a row of button at the top of 
the screen; clicking them reloads the same page (but with a different 
parameter value).  Then based on the value of that parameter, the tree has 
different content, eg:

Button1 -> page.aspx?id=1
Button2 -> page.aspx?id=2
Button3 -> page.aspx?id=3

Page_Load():
switch( id ) {
case 1: tree contains nodes A, B, C; expand/collapse nodes as per cookie 
settings
case 2: tree contains nodes D, E, F; expand/collapse nodes as per cookie 
settings
case 3: tree contains nodes G, H, I; expand/collapse nodes as per cookie 
settings
}

So the tree itself is not responsible for any postback
Date:Thu, 23 Aug 2007 10:23:20 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us