Welcome Guest Search | Active Topics | Sign In | Register

Dynamically adding menu items before static menu items Options
HT
Posted: Sunday, May 11, 2008 8:47:16 AM
Rank: Advanced Member
Groups: Member

Joined: 3/18/2008
Posts: 41
Hello.

I want to add some menu items dynamically to a menu. In addition, I want to show a static (hard coded) menu item. The problem is that the dynamically added menu items are appears AFTER the static item. I want the dynamically added items to be added BEFORE the static item. How can I dynamically add menu items before the hard coded menu item?

Regards,
HT

eo_support
Posted: Monday, May 12, 2008 1:47:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
HT
Posted: Monday, May 12, 2008 3:11:48 PM
Rank: Advanced Member
Groups: Member

Joined: 3/18/2008
Posts: 41
Hmm.. I get the error "Command item already belongs to a control".

This is the situation: I have the following menu item (hard coded in the ASPX page):

Code: HTML/ASPX
<TopGroup>
    <Items>
        <eo:MenuItem Width="250">
            <CustomItem>
                <div style="width:250px;">
                Content of my custom item
                </div>
            </CustomItem>
        </eo:MenuItem>
    </Items>
</TopGroup>


In C#, I add some menu items at runtime. These are by default located after the hard coded menu item above. What I want is the menu items added at runtime to be located before the hard coded item above.

Example: I add 5 menu items at runtime. The hard coded menu item above should then be item number 6.

Thank you.

HT
ROI.Solutions
Posted: Monday, May 12, 2008 3:47:09 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
HT,

I had a similar issue. Are you useing something like an SQL DataSource to dynamically Bind the data? if so read below

I set my menu to use the SQLDataSourceObject I created and then i did a DataBind() to that object. I then After that Added my menu Item. Sample code below. I used Insert because i wanted mine to be the first one to be "Search" but Tools was added to the end. Hope this helps

Code: Visual Basic.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        mainMenu.DataSource = menuData.Select(DataSourceSelectArguments.Empty)
        mainMenu.DataBind()

        Dim item1 As New EO.Web.MenuItem("Search Affiliate")
        item1.NavigateUrl = "EMS_Search.aspx"
        item1.OnClickScript = "hideSearchFrame()"
        mainMenu.Items.Insert(0, item1)

        item1 = New EO.Web.MenuItem("Tools")
        Dim item2 As New EO.Web.MenuItem("User Preferences")
        item2.NavigateUrl = "EMS_DisplayOptions.aspx?LoID=" & Request.Cookies("LOGONID").Value
        item1.SubMenu.Items.Add(item2)
        mainMenu.Items.Add(item1)
    End Sub


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.