Click to See Complete Forum and Search --> : .NET 2.0 version of Node.SelectedImageUrl?


STEVESKI07
09-24-2007, 02:36 PM
I'm converting a web site from 1.1 to 2.0 and I cannot find the solution to this anywhere. Here is my code:

sectionNode.ImageUrl = "..\images\treeview\folder.gif"
sectionNode.SelectedImageUrl = "..\images\treeview\folderopen.gif"

The ImageUrl property still works in 2.0, but the SelectedImageUrl property doesn't. Does anybody know what the new replacement for this is?

lmf232s
09-24-2007, 05:27 PM
steve is this for a control? if so which control?

STEVESKI07
09-24-2007, 05:47 PM
This is for a TreeNode that is just displaying the hierachy of folders and its corresponding pages. Thanks in advance.

lmf232s
09-25-2007, 09:24 AM
I see 2 properties:
ExpandImageUrl
CollapseImageUrl

Here is the web page to the quick start tutorials. This gives you a lot of examples of the treeview as well as every other control in .net 2.0
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/navigation/treeview.aspx

STEVESKI07
09-25-2007, 09:36 AM
Thanks lmf232s. That site is very helpful for future problems, but I still don't see what I'm looking for. The ExpandImageUrl and CollapseImageUrl are for the + and - next to each node. I'm trying to change the picture of the folder (next to the + and -) so when the the node is expanded, it also changes the image of the folder to an opened folder. I have looked everywhere and haven't seen any function that does this in .Net 2.0 or 1.1, so my company must be using some add-on functionality to get this working. I'll go ahead and use the site you gave me to do everything except the folder image changing.

Thanks again.

lmf232s
09-25-2007, 01:31 PM
Steve,

I played with it a bit and was able to accomplish what your after by doing the following:


Protected Sub TreeView1_TreeNodeCollapsed(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodeCollapsed
e.Node.ImageUrl = "~/images/FileManager/Files/closedFolder.gif"
End Sub

Protected Sub TreeView1_TreeNodeExpanded(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodeExpanded
e.Node.ImageUrl = "~/images/FileManager/Files/openFolder.gif"
End Sub


This changes the image when you click on the + or - images of the treeview.

If you click on the actual item then it fires an event
TreeView1_SelectedNodeChanged
and in here you can change the image like this. But note that this just changes the image and will not expand the item.

Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
Me.TreeView1.SelectedNode.ImageUrl = "~/images/FileManager/Files/openFolder.gif"
End Sub


You may need to play with this a bit to get what you want but I dont think it should be ab problem.

Let me know if you have any problems.

STEVESKI07
09-25-2007, 01:47 PM
That's exactly what I needed. I already have the code working to expand the items. Thank you very much, you just made my very stressful day a lot more pleasant.