CodeVerge.Net Beta


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

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 5/10/2007 3:03:06 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 8 Views: 54 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
9 Items, 1 Pages 1 |< << Go >> >|
gndprx
Asp.Net User
asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/10/2007 3:03:06 PM

0/0

I run into this problem often enough that I really do need to find a solution.

How can I have a page show in the bread crumb trail yet not be part of the menu system?  I am using a SQL database generated SiteMap with the asp:menu control.

 

Also along those lines, how can I add dynamicly generated pages to the breadcrumb trail and not the menu?  i.e. article.aspx?id=1234  would simply display "news article" as the last breadcrumb.

Thanks
 

 


 

Dave Sussman
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/11/2007 11:17:16 AM

0/0

This is actually pretty simple, once you know how. First you add a custom attribute to the siteMapNode:

<siteMapNode url="..." title="..." visible="false" />

Next you hook into the MenuItemDataBound event for the Menu:

protected

void Menu2_MenuItemDataBound(object sender, MenuEventArgs e)
{
  SiteMapNode node = e.Item.DataItem
as
SiteMapNode;

 

// check for the visible attribute and if false
 
// remove the node from the parent
 
// this allows nodes to appear in the SiteMapPath but not show on the menu

  if (!string.IsNullOrEmpty(node["visible"]))
  {
   
bool
isVisible;

    if (bool.TryParse(node["visible"], out isVisible))
    {
     
if
(!isVisible)
      {
        e.Item.Parent.ChildItems.Remove(e.Item);
      }
    }
  }
}

This simply checks for the custom attribute (which gets added to the node and is available throught he default collection); if the attribute is present and contains "false" then the item is removed from the menu.

Dave

atsofttech
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/11/2007 11:21:14 AM

0/0

Is that same case http://forums.asp.net/thread/1703669.aspx
Everything is possible!
gndprx
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/11/2007 12:29:55 PM

0/0

Dave,

 

This looks like it may be a good option, but I will have to adapt it a little since my nodes are being generated from a database table.  I will setup a flag in the table for "hide" or whatever and see if I can implement your solution that way.  

 

atsofttech, That link may help solve something else I've been looking into.  Not the same as above, but still good link to have handy.

 

Thanks and I'll let y'all know if any of this helps Big Smile 

 

Dave Sussman
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/11/2007 1:15:41 PM

0/0

Yep, that's all you need to do - add another column. I wrote a db site map provider and had a separate column called attributes. In my provider, when building the site map, I had:

NameValueCollection attributeCollection =

null;

string

attributeString = rdr["attributes"].ToString().Trim();

if

(!string.IsNullOrEmpty(attributeString))

{

attributeCollection =

new NameValueCollection();

string[] attributePairs = attributeString.Split(';');

foreach (string attributePair in attributePairs)

{

string[] attributes = attributePair.Split(':');

if (attributes.Length == 2)

attributeCollection.Add(attributes[0], attributes[1]);

}

}

 

// build node

SiteMapNode node = new SiteMapNode(this

, currentID.ToString(), rdr[

"Url"].ToString()

, rdr[

"Title"].ToString(), rdr["Description"].ToString()

, roleList, attributeCollection,

new NameValueCollection(), ""

);

Dave

gndprx
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/11/2007 1:56:32 PM

0/0

I'm attempting to implement the solution above and have a quick problem (I hope)

 

I put the following in place (modified slightly from above)

     protected void NavigationMenu1_MenuItemDataBound(object sender, MenuEventArgs e)
    {
        SiteMapNode node = e.Item.DataItem as SiteMapNode;

        if (!string.IsNullOrEmpty(node["hideFromMenu"]))
        {
            bool isHidden;
            if (bool.TryParse(node["hideFromMenu"], out isHidden))
            {
                if (isHidden)
                {
                    e.Item.Parent.ChildItems.Remove(e.Item);
                }
            }
        }
    }

 

I then added the following to my asp:menu control:

 OnDataBound="NavigationMenu1_MenuItemDataBound"

 

And this is the error I get when it's called:

 No overload for 'NavigationMenu1_MenuItemDataBound' matches delegate 'System.EventHandler'

 

This may be something simple, but since I'm still in the learning stages of .NET (classic ASP background) I'm not sure where to go from here.

 Thanks!
 

Dave Sussman
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/11/2007 2:16:15 PM

0/0

You need the MenuItemDataBound event, not the DataBound event. I.e.

 OnMenuItemDataBound="..."

Dave

gndprx
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?5/11/2007 4:00:35 PM

0/0

Dave, That 1st solution above works absolutely perfect.

I had to make some modifictions to my custom sitemap provider to add the new field properly, but once I did it all just fell into place.

Thank you Yes

CarlCouture1
Asp.Net User
Re: asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail?11/1/2007 3:48:34 PM

0/0

How about this simple way:

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)

{

     string menuId = e.Item.Value;    

     if (! CanSeeMenuItem(menuId) ) //You'll have to define your CanSeeMenuItem() function

     {

           Menu1.Items.Remove(e.Item);

    }

}

 

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


Free Download:


Web:
asp:menu - how can I hide a node yet still allow it to show in a ... asp:menu - how can I hide a node yet still allow it to show in a breadcrumb trail? Last post 11-01-2007 11:48 AM by CarlCouture1. 8 replies. ...
ASP.NET 2.0 Site Navigation Features - ScottGu's Blog How can we use the SiteMap control but still generate the breadcrumb path above? ... to hide or show certain elements of the Sitemap in my menu based on the ...
Great ASP.NET 2.0 Site Navigation Tutorial Series - ScottGu's Blog NET 2.0 that allows you to automatically show/hide nodes within the site navigation .... How can i bind this to two different controls, say menu to display ...
ASP.NET.4GuysFromRolla.com: Examining ASP.NET 2.0's Site ... Dec 28, 2005 ... These administrative web pages can then be configured to allow access .... Similarly, you may want to show a local site map node to users, ...
ComponentArt Web.UI 2008.2 for ASP.NET - Summary This also means that - even if you are not yet ready to use ASP.NET AJAX/3.5 - you can still take advantage of the AJAX Library JavaScript syntax offered ...
Constructing ASP.NET Web Pages Oct 9, 2008 ... ASP.NET offers features that allow web developers to build parts of ...... In many cases, we won’t want to show the root node; we can hide ...
SimpleBits ~ SimpleQuiz › Part XII: Breadcrumbs If you’re going to convert a breadcrumb trail into a list, then why not a .... An alternative is to explode whatever navigation menu you have to show the ...
Dynamic Elements - cloak and dagger web design | evolt.org While posing less problems than a foldout menu, there are still some pitfalls ... We need to tell users that they can hide and show this part of the page, ...
jQuery iPod-style Drilldown Menu | Filament Group, Inc. May 14, 2008 ... We agree the breadcrumb slide down was a bit distracting, .... Regardless, without javascript, you can still use the menu and if it is being ...
Chapter 6: Building Web Applications Although it's quite easy to do, data binding in ASP.NET 1.1 still ......
) and then writing the logic to show and hide the server ...




Search This Site:










loaded asp.net 1.1 to windows 2000 server. do i need to configure anything else?

login page problem

consuming classes after converting from websiteproject > webapplicationproject.

plz do help me...........

problem in setting focus on image control by other control enter event

javascript error on new install

how to print debug information with asp.net?

server error - machine.config error, help pls

the html and javascript error of my website

playing and downloading audio using .net

"this type of page is not served"-- error on asp files

asp .net not running

dnn user and asp net membership

ispy dotnetnuke conversion

problems with 3.1.1

problem uploading videos and some other music files

reset password direction requested...

class library standard

custom datagrid and template columns

smtp settings

how do i access the value of a stored proc return param in c# using executenonquery?

datagrid column names

how to change dnn tabs to look like ibuyspy tabs?

profile object not picking up username or isannomymous

where is my code snippet manager ?

using the trace in an assembly

bind dynamic controls to database

adding a local project as a reference

could not add aspnet user to sql server

problem creating wizard dynamically please help

 
All Times Are GMT