-1

我在 jquery 中有这个 megamenu 内置在一个列表中,但是要对其进行数据绑定,我正在使用<asp:menu>控件。这个特定的列表,我想在菜单控件中构建,但是菜单控件在标记上放置了自己的 css 类而不是我的。

链接到 megamenu: http: //www.designchemical.com/lab/jquery-mega-drop-down-menu-plugin/options/

我有.net 4并将渲染模式设置为列表..

我试过的:

它仍然将这些 AspNet-Menu-Vertical 放在我想摆脱的标记中。

我的列表:

<li><a href="test.html">Parent</a>
    <ul>
        <li><a href="#">ParentChild</a>
            <ul>
                <li><a href="#">Child</a></li>
                <li><a href="#">Child</a></li>
                <li><a href="#">Child</a></li>
            </ul>
        </li>
    </ul>
</li>

这就是我的硬编码列表呈现的,一个完美的大型菜单。

<ul class="mega-menu" id="mega-menu-1">
    <li class="dc-mega-li">
        <a href="./" class="dc-mega">Ögon<span class="dc-mega-icon"></span></a>
        <div class="sub-container mega" style="left: 0px; top: 50px; z-index: 1000;"><ul class="sub" style="display: none;">
            <div class="row" style="width: 720px;"><li class="mega-unit mega-hdr" style="height: 293px;">
                <a href="#" class="mega-hdr-a" style="height: 18px;">Ögonskuggor</a>
                <ul>
                    <li><a href="#">Bas</a></li>
                    <li><a href="#">Luniere</a></li>
                </ul>
            </li>
</div>



        </ul></div>
    </li>
</ul>

我的菜单代码

<asp:Menu ID="Menu1" runat="server" RenderingMode="List">
        <Items>
            <asp:MenuItem Text="parent" Value="parent 1">
                <asp:MenuItem Text="parentchild" Value="pchild 1">
                    <asp:MenuItem Text="child" Value="child 1"></asp:MenuItem>
                </asp:MenuItem>
            </asp:MenuItem>
        </Items>
    </asp:Menu>

它呈现如下:

<div id="megamenu1" class="AspNet-Menu-Vertical" style="float: left;">
    <ul class="AspNet-Menu static" tabindex="0" style="position: relative; width: auto; float: left;" role="menu">
        <li class="AspNet-Menu-WithChildren has-popup static" aria-haspopup="megamenu1:submenu:2" role="menuitem" style="position: relative;">
            <a class="AspNet-Menu-Link static" href="javascript:__doPostBack('megamenu1','b1')" tabindex="-1">
                Ögon</a>
            <ul id="megamenu1:submenu:2" style="display: none; position: absolute; top: 0px; left: 100%;" class="dynamic">
                <li class="AspNet-Menu-WithChildren has-popup dynamic" aria-haspopup="megamenu1:submenu:3" role="menuitem" style="position: relative;">
                    <a class="AspNet-Menu-Link dynamic" href="javascript:__doPostBack('megamenu1','b1\\2')" tabindex="-1">
                        Ögonskuggor</a>
                    <ul id="megamenu1:submenu:3" style="display: none; position: absolute; top: 0px; left: 100%;" class="dynamic">
                        <li class="AspNet-Menu-Leaf dynamic" role="menuitem" style="position: relative;">
                            <a class="AspNet-Menu-Link dynamic" href="javascript:__doPostBack('megamenu1','b1\\2\\3')" tabindex="-1">
                                Bas</a>
                        </li>
                        <li class="AspNet-Menu-Leaf dynamic" role="menuitem" style="position: relative;">
                            <a class="AspNet-Menu-Link dynamic" href="javascript:__doPostBack('megamenu1','b1\\2\\4')" tabindex="-1">
                                lumiere</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>

请帮忙谢谢

4

2 回答 2

0

呈现为列表的菜单存在问题。我在另一篇文章中回答了我的解决方案。

问候!

于 2015-01-27T10:48:37.120 回答
0

我使用中继器来创建一个干净的列表

    <div>
        <asp:Repeater ID="ParentRepeater" runat="server"  OnItemDataBound="ParentRepeater_OnItemBound">
            <HeaderTemplate>
                <ul>
            </HeaderTemplate>
            <ItemTemplate>
                <li><a><%# DataBinder.Eval(Container.DataItem, "ParentCatName") %></a>
                    <asp:Repeater ID="ParentCatRepeater" runat="server"  OnItemDataBound="ChildRepeater_OnItemBound">
                        <HeaderTemplate>
                            <ul>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <li><a><%# DataBinder.Eval(Container.DataItem, "CategoryName") %></a>
                                <asp:Repeater ID="ChildRepeater" runat="server">
                                    <HeaderTemplate>
                                        <ul>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <li><a><%# DataBinder.Eval(Container.DataItem, "ProductName") %></a></li>
                                    </ItemTemplate>
                                    <FooterTemplate></ul></FooterTemplate>
                                </asp:Repeater>
                            </li>

                        </ItemTemplate>
                        <FooterTemplate></ul></FooterTemplate>
                    </asp:Repeater>
                </li>
            </ItemTemplate>
            <FooterTemplate></ul></FooterTemplate>
        </asp:Repeater>

    </div>

C#

        protected void Page_Load(object sender, EventArgs e)
    {
        LinqtoDBDataContext db = new LinqtoDBDataContext();

        ParentRepeater.DataSource = db.GetParentCategories();
        ParentRepeater.DataBind();
    }

    protected void ParentRepeater_OnItemBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            dynamic cat = e.Item.DataItem as dynamic;
            int parentcatid = Convert.ToInt32(cat.ParentCatID);

            LinqtoDBDataContext db = new LinqtoDBDataContext();

            //var cats = from c in db.Categories
            //           where c.ParentCatID == parentcatid

            //          select c;

            Repeater ParentCatRepeater = e.Item.FindControl("ParentCatRepeater") as Repeater;
            ParentCatRepeater.DataSource = db.GetCategories(parentcatid);
            ParentCatRepeater.DataBind();
        }
    }

    protected void ChildRepeater_OnItemBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            dynamic prod = e.Item.DataItem as dynamic;
            int catid = Convert.ToInt32(prod.CategoryID);

            LinqtoDBDataContext db = new LinqtoDBDataContext();


            Repeater ChildRepeater = e.Item.FindControl("ChildRepeater") as Repeater;
            ChildRepeater.DataSource = db.GetProductsInCategory(catid);
            ChildRepeater.DataBind();
        }
    }

}
于 2014-07-29T11:50:53.223 回答