Welcome Guest Search | Active Topics | Sign In | Register

Dynamic Menu Loading Options
andrew.w
Posted: Monday, June 11, 2012 3:54:50 PM
Rank: Newbie
Groups: Member

Joined: 6/11/2012
Posts: 4
I am looking at this example and I would like to adapt something like this to not only get data from a table, but to also dynamically load it on the page. This way, only the active parts of the menu would get loaded. Is this possible, and are there examples of this being done?

Thanks,
Andrew
eo_support
Posted: Monday, June 11, 2012 3:59:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

You can dynamically build your menu whatever you want:

http://demo.essentialobjects.com/Demos/Menu/Programming/Server%20Side%20Programming/Dynamically%20Modifying%20Menu/Demo.aspx

Loading it from a table is just one of the "shortcut" to load many items at once.

I do not know what you meant by "only the active parts of the menu would get loaded" though. In ASP.NET, the whole page is reloaded every time your page is requested/posted back, so there is no such thing as "only the active parts of the menu would get loaded". It's always a full reload on the server side. The difference is how this reload occurs: whether it's a full reload from your database; or a reload from view state based on post back data, or a combination of both, etc.

Thanks!
andrew.w
Posted: Monday, June 11, 2012 4:19:51 PM
Rank: Newbie
Groups: Member

Joined: 6/11/2012
Posts: 4
I'm talking about client-side. If there are 2 menu items that each have say 50 children elements, I don't want the client to have to download both subtrees if they are only going to look at one of them. I want them to only download the parts of the menu that they are viewing. Does that make any more sense? I want a postback to be triggered on a mouseover/click of an element that potentially has children elements.
eo_support
Posted: Monday, June 11, 2012 4:40:30 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

You can do that with AJAX but I am not sure if it's worth it. Here I will give you the details as to how to load 50 children items for a single root item. It will be something like this:

1. Initially you would have a "root" menu with only one root item (you can have as many root item as you want, just repeat the logic described below). This root item has a single child item. This child item is a dummy "place holder" child item;

2. The dummy "place holder" child item is associated to a "CustomItem" control. CustomItem is a featured provided by our menu that allows you to put anything inside a menu item. You can think "CustomItem" as a standard ASP.NET Panel control that can holds anything else;

3. The CustomItem contains a CallbackPanel. The CallbackPanel then contains a "child menu". This menu has 50 items. This child menu's Visible is initially set to false;

4. When user clicks the root menu item, you make an AJAX call through the CallbackPanel and updates the child menu's visible to true;

Note this method has the following implications:
1. There is a time delay between the time user clicks the menu item and the time all child items are loaded. This usually will confuse users as they expect a menu to instantly opens it sub menu;
2. This will reduce the initial page load time but will not save you on band width as it introduces a second post back;

Overall I would suggest you against this solution because a menu supposes to be instant. If you have to dynamically load child items, consider using a TreeView together with the populate on demand feature.

Hope this helps.

Thanks
andrew.w
Posted: Monday, June 11, 2012 4:43:10 PM
Rank: Newbie
Groups: Member

Joined: 6/11/2012
Posts: 4
Thanks. I think that should work. I am aware that there will be a bit of a delay, but for my purposes, that is acceptable.
andrew.w
Posted: Tuesday, June 12, 2012 3:01:43 PM
Rank: Newbie
Groups: Member

Joined: 6/11/2012
Posts: 4
Okay, I'm trying to work through this a bit and I have another question.

If I programatically add a MenuItem and set RaisesServerEvent = true, how do I create a handler for it server-side?

Thanks.
eo_support
Posted: Tuesday, June 12, 2012 4:37:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

You never need to create a handler for the MenuItem. Server side event is handled on the Menu, not on the MenuItem. So you would always handle the item click event at a single place no matter how many menu items you have.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.