Welcome Guest Search | Active Topics | Sign In | Register

Sliding Menu - hide menu item based on Session variable? Options
Kathy Burke
Posted: Tuesday, June 12, 2007 4:30:38 PM
Rank: Newbie
Groups: Member

Joined: 6/10/2007
Posts: 7
I see BaseNavigator.HideRoleDisabledItems Property allows use of roles. However, I'm not using roles but assigning certain session variables for example ("Executive") so only certain users can see certain menu items/links.

I'm assuming I can do this in the page load event but could you please point me to an example that will do this?

thanks,
Kathy
eo_support
Posted: Tuesday, June 12, 2007 4:52:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Kathy,

Thanks for posting at here. You will do something like this:

Code: Visual Basic.NET
Menu1.Items(0).SubMenu.Items(1).Visible = False


The above code hide the second child item of the first top level item.

You can also use a If branch to turn off some menu items:

Code: Visual Basic.NET
If IsExecutive Then
   Menu1.Items(0).Visible = True
Else
   Menu1.Items(0).Visible = False
End If


The above code show/hide the first top level item based on your condition.

Please feel free to let us know if you have any more questions.

Thanks
Kathy Burke
Posted: Tuesday, June 12, 2007 5:09:06 PM
Rank: Newbie
Groups: Member

Joined: 6/10/2007
Posts: 7
This is certainly what I need to do:

If IsExecutive Then
Menu1.Items(0).Visible = True;
Else
Menu1.Items(0).Visible = False;
End

...but how to know which item I'm making visible. Do I check the html value or something?

thanks for the quick answer.

/k (slow learner)
eo_support
Posted: Tuesday, June 12, 2007 5:15:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
The answer to that question usually roots back to how you created the menu item. If you created the menu item in code, you would instantly know which item you will be making visible. Otherwise you usually would reply on the index,

Menu1.Items(0).Visible = False

Hide the first item,

Menu1.Items(1).Visible = False

Hide the second item, and so on. I am assuming that you know which items are for "Executive", which items are for "Accoutings", ect. Thus you would know their item index.

Thanks
Kathy Burke
Posted: Wednesday, June 13, 2007 6:32:56 AM
Rank: Newbie
Groups: Member

Joined: 6/10/2007
Posts: 7
In the page load event I'm using this code and physically counted the instances of <eo:menuitem> to get the index.

If Session("EnterPostPour") = False Then
SlideMenu1.Items(60).Disabled = True
End If

I get this error: (please, where am I going wrong?)

System.ArgumentOutOfRangeException was unhandled by user code
Message="Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
ParamName="index"
Source="mscorlib"
StackTrace:
at System.Collections.ArrayList.get_Item(Int32 index)
at EO.Web.Internal.am.a(Int32 A_0)
at EO.Web.NavigationItemCollection.a(Int32 A_0)
at EO.Web.MenuItemCollection.get_Item(Int32 index)
at MainMenu.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Kathy\My Documents\Visual Studio 2005\WebSites\BPM-PI\MainMenu.aspx.vb:line 18
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Kathy Burke
Posted: Wednesday, June 13, 2007 6:40:57 AM
Rank: Newbie
Groups: Member

Joined: 6/10/2007
Posts: 7
More info...I have a series of menu/submenu/submenu items...trying to figure out how they index.
<eo:MenuItem Text-Html="Logistics" NormalStyle-CssText="color:dimgray;">
<SubMenu>
<Items>
<eo:MenuItem Text-Html="Store Product" NormalStyle-CssText="color:dimgray;">
</eo:MenuItem>
<eo:MenuItem Text-Html="Ship Product" NormalStyle-CssText="color:dimgray;">
</eo:MenuItem>
<eo:MenuItem Text-Html="View/Manage Storage" NormalStyle-CssText="color:dimgray;">
</eo:MenuItem>
<eo:MenuItem Text-Html="View/Manage Transportation" NormalStyle-CssText="color:dimgray;">
<SubMenu>
<Items>
<eo:MenuItem Text-Html="Schedule Shipments" NormalStyle-CssText="color:dimgray;">
</eo:MenuItem>
<eo:MenuItem Text-Html="View Location Information" NormalStyle-CssText="color:dimgray;">
</eo:MenuItem>
</Items>
</SubMenu>
</eo:MenuItem>
</Items>
</SubMenu>
</eo:MenuItem>
eo_support
Posted: Wednesday, June 13, 2007 6:48:46 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
That is wrong. The index are for a specific level only. It's like your room is "the fourth room on the third floor", there is an index number involved on each logical level. People would be really confused if you tell them your room is the "37th room of the building".

So:

Menu1.Items(0) refer to the first top level item.

Menu1.Items(1) refer to the second top level item

Menu1.Items(0).SubMenu.Items(2) refer to the first top level item's third child item

Menu1.Items(0).SubMenu.Items(2).SubMenu.Items(5) refer to the first top level item's third child item's sixth child item.

and so on.
Kathy Burke
Posted: Wednesday, June 13, 2007 7:30:09 AM
Rank: Newbie
Groups: Member

Joined: 6/10/2007
Posts: 7
thanks. makes sense. I have one remaining issue, then I'm done with this...really.

I have put the slidemenu control in the MasterPage.aspx, included the <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>, etc.

On MasterPage page load I have this:

Dim item2 As EO.Web.MenuItem
For Each item2 In SlideMenu1.Items
If item2.SubMenu.Items.Count = 0 Then
item2.LeftIcon.Url = "Blank"
item2.LeftIcon.ExpandedUrl = "Blank"
End If
Next

I get an error saying:

System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_Web_masterpagewithmenu.master.cdcab7d2.f4chkuz-"
StackTrace:
at MasterPageWithMenu.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Kathy\My Documents\Visual Studio 2005\WebSites\BPM-PI\MasterPageWithMenu.master.vb:line 8
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


eo_support
Posted: Wednesday, June 13, 2007 7:39:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Which line is line 8? Try open the master page in design view and change the ID of the slide menu to something else and then change it back to see if it helps.
Kathy Burke
Posted: Wednesday, June 13, 2007 7:48:46 AM
Rank: Newbie
Groups: Member

Joined: 6/10/2007
Posts: 7
This is were it catches...

For Each item2 In SlideMenu1.Items

I tried your suggestion, no luck.

/k
eo_support
Posted: Wednesday, June 13, 2007 8:12:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
I have no idea why it does that....I have scheduled an online meeting for you so that we can take a look. Please see your private messages for the link to the meeting.


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.