Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MenuItem no attributes? alternatives?

Status
Not open for further replies.

johnfraser

Programmer
Jul 25, 2007
33
US
I have a menu system that populates it's items by data binding. The menu itself we have a java script function attached as an attribute that checks to see if the menu item clicked is of special type.

Unfortunately the defect is when the menu items have children. When I click on the children my javascript function doesn't fire... easy enough, I thought, I'll simply cycle through the items and add the function to their onselect as an attribute..... not the case... apparently menu items do not have attributes so my idea was sunk.

So here is the problem. I have a javascript function that needs to be called when I click on a Menu.Items.ChildItems[j] What is the best way of doing this?
 
1. manually build your menu using nested repeaters and/or nested web user controls.
2. parse through the asp:menu control to find the link control and use Control.Attributes.Add(); to add client functions to the menu.
3. use the menu provided with CSS Friendly Adapters and try to hook into the objects.

1. would probally be your best option.
create a web user control which contains a repeater.
create a pulblic property to set your datasource.
in the itemdatabound event of the repeater create a new instance of the web user control and set the datasource to the current nodes childern.

now you have complete control over how the menu operates.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top