Menu problems

Last post 05-13-2008 5:06 PM by tyrben@rocketmail.com. 4 replies.

Sort Posts:

  • Menu problems

    05-09-2008, 5:28 AM

    Hi,

    Hope someone can help me with this problem.

     My problem is to get the top-level in my menu without link. I only want to have the top-level as header and then the childnodes as links.

     Here is the code:

    Sub PopulateMenu()

    Dim dst As System.Data.DataSet = GetMenuData()

    For Each masterRow As System.Data.DataRow In dst.Tables("tbl_HeadMenu").Rows()

    Dim masterItem As New MenuItem(masterRow("LinkName").ToString())

    Menu1.Items.Add(masterItem)

    For Each childRow As System.Data.DataRow In masterRow.GetChildRows("Children")

    If (childRow("UrlCategory")) = 1 Then

    Dim childItem As New MenuItem(childRow("LinkName").ToString(), "SomeValue", String.Empty, (childRow("ExternUrl").ToString))

    masterItem.ChildItems.Add(childItem)

    ElseIf (childRow("UrlCategory")) = 2 Then

    Dim childItem As New MenuItem(childRow("LinkName").ToString(), "SomeValue", String.Empty, "~/default2.aspx?page=SPage&HId=" & (childRow("HId").ToString) & " &PId=" & (childRow("PIdIntern").ToString))

    masterItem.ChildItems.Add(childItem)

    Else

    Dim childItem As New MenuItem(childRow("LinkName").ToString(), "SomeValue", String.Empty, "~/default2.aspx?page=SPage&HId=" & (childRow("HId").ToString) & " &PId=" & (childRow("PId").ToString))

    masterItem.ChildItems.Add(childItem)

    End If

    Next

    Next

    End Sub

     

    Hope anyone can help me?!

     Regards T

  • Re: Menu problems

    05-11-2008, 8:15 PM
    • Loading...
    • Peter Lee
    • Joined on 07-02-2007, 4:34 PM
    • Virginia, USA
    • Posts 65

    Hi T,

     You can set the NavigateUrl, either at design time as an attribute on the menuitem tag, or programmatically using the navigateurl parameter, to

    NavigateUrl="javascript: void(0);"

     That will create a dead link.

    Pete

  • Re: Menu problems

    05-12-2008, 5:20 PM

    Hi

    Thanks for your help.  I don´t use the menu item tag in Design view so I have to fix it in codebehind. Can you show me some more code I would be very glad because I´m lost.

     I have to fix it here I think:

    For Each masterRow As System.Data.DataRow In dst.Tables("tbl_HeadMenu").Rows()

    Dim masterItem As New MenuItem(masterRow("LinkName").ToString())

    Menu1.Items.Add(masterItem)

     

    <asp:Menu id="Menu1" Orientation="Horizontal" Runat="Server" Height="25px" SkinID="HeadMenu" Width="550px" style="text-align: center">

    <StaticMenuStyle BackColor="#9C9D9E" BorderStyle="Solid" BorderColor="Black" BorderWidth="0px" />

    <DynamicMenuStyle BorderStyle="Solid" BorderColor="Black" BorderWidth="0px" />

    <DynamicHoverStyle Font-Underline="True" />

    <StaticSelectedStyle Font-Underline="True" />

    <DynamicSelectedStyle Font-Underline="False" />

    <DynamicMenuItemStyle Font-Underline="True" />

    <StaticHoverStyle Font-Underline="True" />

    </asp:Menu>

     

    Thanks Tobias

  • Re: Menu problems

    05-12-2008, 11:22 PM
    Answer

    Hi,

    tyrben@rocketmail.com:
    Thanks for your help.  I don´t use the menu item tag in Design view so I have to fix it in codebehind. Can you show me some more code I would be very glad because I´m lost.

    The menuItem has 6 override methods, you can try to do like this:

    For Each masterRow As System.Data.DataRow In dst.Tables("tbl_HeadMenu").Rows()Dim masterItem As New MenuItem(masterRow("LinkName").ToString(), "", "", "javascript: void(0);")

    Menu1.Items.Add(masterItem)

    Hope it helps.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Yours sincerely,
    Amanda Wang
    Microsoft Online Community Support
  • Re: Menu problems

    05-13-2008, 5:06 PM

    Thank you it works perfect!

     

    Best regards Tobias

Page 1 of 1 (5 items)