|
Rank: Member Groups: Member
Joined: 4/9/2010 Posts: 12
|
Hello,
I have a slide menu with some child items. When I click the parent menu item it expands as it should, but it instantly contracts again.. so when I click the parent item I see the child menu items but only for a second. Any suggestions on how to keep the parent menu expanded until I click it again? Basically I want my menu to work the same way as the slide menu demo on this website.
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Please check whether you are setting the menu item's NavigateUrl that actually loads a different page when clicked. This is often the source of confusion when you use master page and have slide menu inside the master page. The slide menu contracts because the first page has been completely unloaded and the second page is a brand new page. Even though they user the same master page.
If this is the case, you can try to set the slide menu's AutoSelectSource to "NavigateUrl". That way the slide menu will try to automatically matches the current page Url with menu item's NavigateUrl property. If a match is found, that menu item is selected (expanded).
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/9/2010 Posts: 12
|
I have that done already - same issue. I actually hadn't even given it a url yet, I am just learning the control. I will say this - I think my issue is persisting the menu state across a postback or update panel refresh. What is the best way to do that? Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
There are several ways to keep the state. One way is to set the slide menu's SaveStateCrossPage to true. You can also use UpdatePanel but that means everything stays in the same page. As long as you reload a page, UpdatePanel would have no use to you.
If you are just learning the control, the easiest way to get the same result as the sample is probably just to copy the sample code. You can then make changes step by step and observe what occurs.
If you can isolate the issue into a single test page or a test project, we will be happy to take a look. Please make sure the test page/test project contains only code needed to demonstrate the problem and also runs independently. As soon as we can run it and sees what you are seeing, we should be able to tell you why. If you would like to go with this please let us know so that we can provide you email address.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/9/2010 Posts: 12
|
I was able to get everything working as intended, but one thing I can't seem to do is have a top level menu item enter a click handler if it has sub menu items. All other top level items enter the handler but the ones with sub menus. My page is totally code generated, and I am assigning the handler like this: AddHandler MainMenu1.ItemClick, AddressOf MenuClick ... again, this works perfectly for all menu items except top level items with sub menu items.
If I use the ClientSideOnItemClick property on the top level item it works and calls that function, but i'd rather just have it go into the MenuClick sub I created like all the other menu items so I dont need to manage javascript just for my 2 menu items that have sub menu items. Suggestions?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, That behavior is by design for slide menu because the top level items are dedicated to expand/collapse sub menus. The easiest way to have all items to trigger server event is to use a ScriptEvent control together with ClientSideOnItemClick. The code will be something like this:
Code: HTML/ASPX
<eo:SlideMenu ClientSideOnItemClick="item_click" ...>
...
</eo:SlideMenu>
Code: JavaScript
function item_click(e, info)
{
//Triggering the ScriptEvent's Command event, passing the clicked
//item's "path" as event argument
eo_TriggerServerEvent(
"ScriptEvent1", "anything", info.getItem().getPath());
}
You can then handle the Command event on the server side for the ScriptEvent control. Inside your event handler you can do something like this:
Code: C#
//Get the item that has been clicked
EO.Web.NavigationItem item = SlideMenu1.FindItem(e.CommandArgument);
//Cast it to a menu item if you need to
EO.Web.MenuItem menuItem = (EO.Web.MenuItem)item;
//Do something else
.....
Note that you no longer need to handle the SlideMenu's ItemClick event. Thanks!
|
|