CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Members   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 9/25/2007 2:45:36 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 6 Views: 27 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
7 Items, 1 Pages 1 |< << Go >> >|
mandercruso
Asp.Net User
Treeview hide sitemap node...9/25/2007 2:45:36 PM

0/0

I have a Sitemap with SiteMapNodes 1, 2, 3 and 4. I have a treeview on a page that is connected to this Sitemap. When the page loads, I do not want item 2 to appear. I still need to include Item 2 in my Sitemap so that it will appear in my SiteMapPath that I use on all pages. How can I do this in my codebehind?

 Thanks in advance,

Amanda

GillouX
Asp.Net User
Re: Treeview hide sitemap node...9/26/2007 6:28:17 AM

0/0

can you give us an example because I don't follow you so well 

Coppermill
Asp.Net User
Re: Treeview hide sitemap node...9/26/2007 11:57:32 AM

0/0

 One way would be to create a method to read all the elements of the sitemap and then bind the method using a List to your DDL. 

 This way you can control what is being shown or not shown.

Regards

<<<Bryan Avery>>>
mandercruso
Asp.Net User
Re: Treeview hide sitemap node...9/26/2007 1:50:59 PM

0/0

Let me try to explain it better using code examples.

My sitemap contains:

<siteMapNode url="enrollments.aspx" title="enrollments" description="enrollments">

<
siteMapNode url="addenrollment.aspx" title="add enrollment" description="add enrollment"/>
<siteMapNode url="addclubenrollment.aspx" title="add club enrollment" description="add club enrollment"/>
<
siteMapNode url="reenrollenrollment.aspx" title="reenroll club member" description="reenroll club member"/>
<
siteMapNode url="editenrollment.aspx" title="edit club member" description="edit club member"/>
<
siteMapNode url="viewenrollment.aspx" title="view club member" description="view club member"/>
<
siteMapNode url="deleteenrollment.aspx" title="delete club member" description="delete club member"/>

</siteMapNode>

On enrollments.aspx I have a treeview connected to a SiteMapDataSource as follows:

<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ImageSet="Simple" NodeIndent="10">

<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#DD5555" />
<SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" ForeColor="#DD5555" />
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="0px" />

</asp:TreeView>

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" StartFromCurrentNode="True" />

 When enrollments.aspx is loaded, I don't want "add club enrollment" to appear in the treeview. How can I acheive this? 

 

Amanda Wang - M
Asp.Net User
Re: Treeview hide sitemap node...9/27/2007 6:50:36 AM

0/0

Hi Amanda,

You can the remove method of the treeview to remove the node that you donot want to display, adn the will not change the sitemap file.

Below is a sample:

 protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
    {
        System.Web.UI.WebControls.TreeView tree = (System.Web.UI.WebControls.TreeView)sender;
        SiteMapNode mapNode = (SiteMapNode)e.Node.DataItem;
       
        if (mapNode.Title == "Default2")
        {
            System.Web.UI.WebControls.TreeNode parent = e.Node.Parent;
            if (parent != null)
            {
                parent.ChildNodes.Remove(e.Node);
            } 
        }
    }
 Hope it helps.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
mandercruso
Asp.Net User
Re: Treeview hide sitemap node...9/27/2007 2:10:00 PM

0/0

That was it. Thanks so much!

ovaisgeo
Asp.Net User
Re: Treeview hide sitemap node...1/21/2008 12:46:10 PM

0/0

its working great

7 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

how to allow only one node expansion in treeview? - newsgroup.asp-net ... ... TreeView: ASP Alliance : ASP.NET 2.0 TreeView is bindable with one sitemap per ... unable to set the value of hidden field on master page. problem loading ...
Jeff Prosise's Blog : Hiding the Root Node from SiteMapPath ASP.NET developers often set SiteMapDataSource's ShowStartingNode property to false to hide the root node from TreeView and Menu controls. Unfortunately, that ...
TreeView Class (System.Web.UI.WebControls) Do not use the MaxDataBindDepth property to hide data. Dynamic Node Population ... <siteMap> <siteMapNode title="Home" description="Home" url="default.aspx" ...
Hide sitemap node when the user has logged in - ASP.NET Forums Hide sitemap node when the user has logged in. Last post 08-08-2008 10:51 ... ItemDataBound event of your menu (or treeview) and removing the explicit nodes. ...
Get TreeView Node By Text The boolean variable AVisible is used to make the node visible (if hidden) ... SiteMap. All Topics. Reprints. Help. User Agreement. Ethics Policy. Patent Info. ...
ASP.NET Tutorial ... that can be expanded and contracted to reveal or hide nodes of the tree. ... the set of Nodes in a TreeView, as shown in the following SiteMap.xml file used ...


 
All Times Are GMT