ASP.. NET 4菜单控件删除CSS
本文关键字:删除 CSS 控件 菜单 NET ASP | 更新日期: 2023-09-27 18:15:27
我在jquery中构建了一个列表,但是要绑定它,我使用<asp:menu>
控件。这个特定的列表,我想在菜单控件中构建,但是菜单控件在标记上放了自己的css类,而不是我的。
链接到megamenu: http://www.designchemical.com/lab/jquery-mega-drop-down-menu-plugin/options/
我有。net 4和设置渲染模式为列表。
我已经试过了:
- https://code.google.com/p/aspnetcontroladapters/wiki/Menu
- http://cssfriendly.codeplex.com/
- 把重要的放在我所有的css
- .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>
请帮助由于
我使用了一个重复器来创建一个干净的列表
<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();
}
}
}
显示为列表的菜单有一个问题。我在另一篇文章中回答了我的解决方案。
问候!