|
Rank: Newbie Groups: Member
Joined: 12/28/2007 Posts: 5
|
I am using the TreeView control for navigation for download files. The files are contained in a SQLServer DB. Some of the tree nodes will initiate a download and others are just for navigation to a specific download file so the property RaisesServerEvent = True is set only on nodes that can trigger a download. I have populated the ItemID with a ID that will be used in a SQL statement to select the download file.
I am using a vb code behind file, but can't seem to figure out how to call the node itemclick event on the aspx page and what vb code to use to handle the click event. I don't need help with the SQL, just a simple example of what I use in the aspx page and the vb code to handle the node itemclick event to do something like change the text of a label would get me going.
Probably pretty simple stuff, but I am pretty green on web based programming. I am using MS Expression Web as the development environment.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The easiest way for you is to set RaisesServerEvent to true on the TreeView object. This way all nodes, except for those with NavigateUrl set, will trigger server side ItemClick event, that should work exactly for your purpose.
If you still have problem get ItemClick event triggered, try it with a blank form. Usually the code the designer genearated for you would work just fine. If you use Visual Studio, just double click the TreeView control on the design surface should create an empty ItemClick handler for you because ItemClick is TreeView's default event.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 12/28/2007 Posts: 5
|
OK, I am not using VS but Expresseion Web, but I think I have figured out the RaisesServerEvent. What was confusing was that if for example, I create a asp button on a aspx page I have to use something like OnClick="btnID". Since the download files are actually in a DB, then I won't be using a url to get the file, but rather SQL, which I know how to do. The node itemid is a column in my DB so by using it in a SELECT stmt I can get the file for the clicked node.
Now what is the vb to get the itemid for the node that is clicked and show that id as label text for a lable on the page?
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, That's very easy. The second parameter of ItemClick event should give you everything you need, for example:
Code: Visual Basic.NET
Protected Sub TreeView1_ItemClick(
ByVal sender as Object, ByVal e as EO.Web.NavigationItemEventArgs)
'Display the ItemID of the clicked node
Label1.Text = e.TreeNode.ItemID
End Sub
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 12/28/2007 Posts: 5
|
Ok it must be something simple but so far no joy. When I click a tree node the label text doesn't change.
Here is what I have on the aspx page for the tree and the label:
<eo:TreeView ID="TreeView1" runat="server" ControlSkinID="None" Height="400px" Width="230px" RaisesServerEvent="True"> <LookNodes> <eo:TreeNode ExpandedImageUrl="00030302" ItemID="_Default" SelectedStyle-CssText="background-color:#316ac5;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:White;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;" NormalStyle-CssText="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; COLOR: black; BORDER-TOP-STYLE: none; PADDING-TOP: 1px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none" DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;color:Gray;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;" CollapsedImageUrl="00030301" ImageUrl="00030301"> </eo:TreeNode> </LookNodes> <TopGroup Style-CssText="border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;" RaisesServerEvent="True"> <Nodes> <eo:TreeNode ItemID="1" Text="Drawings" CustomItemID="" RaisesServerEvent="True"> <SubGroup><Nodes> <eo:TreeNode ItemID="1.1" Text="90 Minute Rated Details" CustomItemID="" RaisesServerEvent="True"> <SubGroup><Nodes> <eo:TreeNode ItemID="1.1.1" Text="2 Inch Trim" CustomItemID="" RaisesServerEvent="True"> <SubGroup><Nodes> <eo:TreeNode ItemID="1.1.1.1" Text="DWG Files" CustomItemID="" RaisesServerEvent="True"> </eo:TreeNode> </Nodes> </SubGroup> </eo:TreeNode> <eo:TreeNode ItemID="1.1.2" Text="Flush Trim" CustomItemID="1.1.2" RaisesServerEvent="True"> <SubGroup><Nodes> <eo:TreeNode ItemID="1.1.2.1" Text="DWG Files" CustomItemID="" RaisesServerEvent="True"> </eo:TreeNode> </Nodes> </SubGroup> </eo:TreeNode> <eo:TreeNode ItemID="1.1.3" Text="Reveal Trim" CustomItemID="" RaisesServerEvent="True"> <SubGroup><Nodes> <eo:TreeNode ItemID="1.1.3.1" Text="DWG Files" CustomItemID="" RaisesServerEvent="True"> </eo:TreeNode> </Nodes> </SubGroup> </eo:TreeNode> </Nodes> </SubGroup> </eo:TreeNode> </Nodes> </SubGroup> </eo:TreeNode> </Nodes> </TopGroup> </eo:TreeView> <asp:Label runat="server" Text="TreeNodeID" id="Label1"></asp:Label>
Here is the vb code: Namespace EO.Web.TreeView1.Programming Partial Class DownloadTree Inherits System.Web.UI.UserControl Protected Sub TreeView1_ItemClick( ByVal sender as Object, ByVal e as EO.Web.NavigationItemEventArgs)
'Display the ItemID of the clicked node Label1.Text = e.TreeNode.ItemID
End Sub End Class End Namespace
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You need to add OnItemClick to hookup the TreeView and the item click handler, just like what you have discovered for a standard ASP.NET button:
Code: HTML/ASPX
<eo:TreeView OnItemClick="TreeView1_ItemClick" ....>
.....
</eo:TreeView>
Thanks
|
|