Solved

How To Clone an ASP Menu Control's MenuItems

Posted on 2009-04-02
3
385 Views
Last Modified: 2012-05-06
I created a class that manages the creation of all MenuItems to a Menu Object.  Once my class finishes, it returns a single MenuItem reference (which I call ROOT), under which all other MenuItems are attached.  I store this object reference using a Session Variable so that I can access it through my Web Application.  In the header portion of my MasterPage, I placed code that takes the Session Menu Reference, and looks at each of the ROOT's ChildItems, and attaches them to it's Menu control.  I was hoping that this way, I have one prebuilt master menu tree structure, that all pages can just use when they load.  Here is my problem...When I .Add() the ChildItem from ROOT to the current pages Menu Object, it physically changes the parent reference on the ChildMenuItem to the ne Menu object, thereby literally ripping it off ROOT.  I tried creating a method where I passed ROOT ByVal in the hopes it would create a copy rather then use a reference, no luck.  I looked for a Clone() method on the MenuItems object, no such luck there either.

Somehow I need to create a clone of ROOT, so that when I rip off each ChildItem, I don't actually disturb the original MenuTemplate ROOT in memory, so that when the use navigates to a new page, the new page can access the original ROOT menu object and rebuild the menu again.

Any ideas?

So far, the only option I can see (which I am not fond of) is creating my own Clone() method in my class which manually creates a copy of the entire tree structure of the ROOT object...
0
Comment
Question by:Ben Santiardo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
_Stilgar_ earned 500 total points
ID: 24057411
You should have posted this under .NET regions, not ASP classic.

Anyway, this seems like you need to override Clone() and implement your own logic, correct. That's fairly simple, though...
0
 

Author Comment

by:Ben Santiardo
ID: 24058920
Oh sorry, being that it was an ASP Control I figured this was the right section.  My mistake...I just created a method that recursively traverses the MenuItem Tree and creates a new MenuItem tree.  It was the only way I could see getting this to work.
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question