Welcome Guest Search | Active Topics | Sign In | Register

Set Expanded property by program Options
Corobori
Posted: Tuesday, March 18, 2008 9:53:58 AM
Rank: Member
Groups: Member

Joined: 7/12/2007
Posts: 24
Let me try to explain my question.

I have a menu like this:

Menu1
Submenu1_1
Submenu1_2
Submenu1_3
Submenu1_4
Menu2
Submenu2_1
Submenu2_2
Submenu2_3
Menu3
Submenu3_1

I have my menu in a master page file using ASP.NET 2.0 . I want that if the user click on Subbemenu1_2 that submenu stays Expanded. Setting the Expanded option from the menu builder works fine but I can't do this by program.

I tried this but it doesn't appear to work as expected

Code:

    Protected Sub Menu1_ItemClick(ByVal sender As System.Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles Menu1.ItemClick

        If e.MenuItem.ItemID = "QSMision" Then
            e.MenuItem.Expanded = True
            Response.Redirect("QSMision.aspx")
        ElseIf e.MenuItem.ItemID = "SERVCentrodeVentas" Then
            e.MenuItem.Expanded = True
            Response.Redirect("SERVCentrodeVentas.aspx")
        End If
    End Sub

eo_support
Posted: Tuesday, March 18, 2008 10:27:05 AM
Rank: Administration
Groups: Administration

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

Take a lot of SaveStateCrossPages property. When you are redirecting to another page, everything is start over, even if use the same master page.

Thanks
Corobori
Posted: Tuesday, March 18, 2008 12:38:01 PM
Rank: Member
Groups: Member

Joined: 7/12/2007
Posts: 24
Besides setting the SaveStateCrossPages to True is the approach I am using in my code shown above the right way to do what I want to achieve or should I better use the NavigateUrl Property ?
eo_support
Posted: Tuesday, March 18, 2008 1:20:35 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,098
Yes. You should use NavigateUrl. SaveStateCrossPages works with NavigateUrl by default.
Corobori
Posted: Wednesday, March 19, 2008 7:28:23 AM
Rank: Member
Groups: Member

Joined: 7/12/2007
Posts: 24
Is there any sample showing to do what I want ? I spend quite some time trying different options such as using KeepExpandedOnClick="True" for the menu; Expanded="True" for all submenues; using the ItemClick on the server side, etc. but couldn't figure out the right way.
eo_support
Posted: Wednesday, March 19, 2008 7:35:25 AM
Rank: Administration
Groups: Administration

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

Are you using slide menu? Both Expanded and KeepExpandedOnClick are for menu, not slide menu. For slide menu you should rely on Selected an related property (for example, AutoSelectSource).

In any case, you should avoid "coding" it at all. Just let the slide menu to expand/collapse for you by itself. If you give top level item NavigateUrl (that is, you want clicking a top level item to both expand the pane and also navigate to another page), you will need to set AutoSelectSource to NavigateUrl. Please refer to help file for more details.

Thanks
Corobori
Posted: Wednesday, March 19, 2008 7:57:14 AM
Rank: Member
Groups: Member

Joined: 7/12/2007
Posts: 24
I am not using the Slide Menu.

I tried specifiying Expanded="true" for each menu; indeed it keeps the submenu expanded but the one which is expanded is the last one and not the one I clicked.
See below I clicked on "Mision" but the expanded menu is the one under "Enlaces"


I then removed the "Expanded=true" in Enlaces and clicked once again in "Mision" and the expanded menu is under "Informaciones" which is now the last menu with that option
eo_support
Posted: Wednesday, March 19, 2008 8:06:03 AM
Rank: Administration
Groups: Administration

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

That's another reason why you should avoid setting Expanded by code. When you set Expanded by code, whatever you've set is remembered. Since any time there can be only one expanded item, the last expanded item is the one that takes effect ---- that's the last expanded item in the menu, not the item that was last set as expanded.

In your case, you should set an intial Expanded item (through Menu Builder, for example), set NavigateUrl and let the menu to do the rest. There is absolutely no need for you to have RaisesServerEvent set to true and then do redirect and manually expand the clicked item.

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.