0

I have a page which has a tree directory of people who work at this company. Initially the only way to open the nodes was to click on the little +/- but when you get to the last level, the person's name was there and clickable off to their bio page. I have since fixed it to where the text will also expand the node, but now the name is not clickable anymore. It still has the "link" look (blue, underlined, changes red when hovered over) but the icon stays as the same and does not turn to the finger. Thank you in advance!

Here is the code on the page...

<%@ Control language="C#" Inherits="Modules.PeopleNav.PeopleByAlpha" CodeFile="PeopleByAlpha.ascx.cs" AutoEventWireup="true"%>
<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1" 
    ExpandDepth="1" onselectednodechanged="TreeView1_SelectedNodeChanged" OnTreeNodeDataBound="TreeView1_TreeNodeDataBound">
     <DataBindings>
     <asp:TreeNodeBinding DataMember="Person" ValueField="Value"  TextField="Name">
      </asp:TreeNodeBinding> 
      <asp:TreeNodeBinding DataMember="AlphaBreak"  TextField="Name">
      </asp:TreeNodeBinding> 
      <asp:TreeNodeBinding DataMember="PeopleAlpha" TextField="Name">
      </asp:TreeNodeBinding>
   </DataBindings> 
</asp:TreeView><br />

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Portals/0/Docs/PeopleAlpha.xml"></asp:XmlDataSource>

And the code behind...

   protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
    String sURL = TreeView1.SelectedNode.Value.ToString();
    if (sURL.Length > 5)
    {
        String sExt = sURL.Substring(sURL.Length - 4, 4);
        if (sExt == "aspx")
        {
            Response.Redirect(sURL);
        }
    }
}
          protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
{
    e.Node.SelectAction = TreeNodeSelectAction.Expand;
}
Peter
  • 427
  • 4
  • 9
  • 37

1 Answers1

1

I guess you should set the NavigateUrl property of the nodes :

protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
{
  e.Node.SelectAction = TreeNodeSelectAction.Expand;
  e.Node.NavigateUrl = // extract the url from your e.Node.DataItem
}

This way, I Also think you don't need the TreeView1_SelectedNodeChanged anymore

jbl
  • 15,179
  • 3
  • 34
  • 101
  • The navigate goes to an XML file with all the listings. How do I link the nodes to the XML file dynamically? – Peter Mar 23 '12 at 19:06
  • You should build the url exactly the same way as you build it in your TreeView1_SelectedNodeChanged, and leave it empty when the node should not be clickable – jbl Mar 23 '12 at 21:52