动画工作顺便说一句,每当我点击菜单时,子菜单都会自动下拉。现在的问题是,每当我点击子菜单上的项目时,它就会在过滤数据表时折叠。
继承我的代码:
<div id="contentWrapper">
<ul id="leftNavigation">
<li><a href="#"><i class="leftNavIcon"></i>Hardware</a>
<asp:ListView ID="lvHardware" runat="server">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<ul>
<li>
<asp:LinkButton ID="lbSidebar" runat="server" CssClass="submenuLink" OnClick="lbSidebar_Click" CommandArgument='<%#Eval("TableKey")+";"+Eval("TableValue")%>'><i class="glyphicon glyphicon-menu-right leftNavIcon"></i><%#Eval("TableValue")%></asp:LinkButton>
</li>
</ul>
</ItemTemplate>
</asp:ListView>
</li>
</ul>
</div>
repeaterAssets是我桌子的另一个转发器。我使用动态链接按钮来过滤我的表格内容
codebehind:
protected void lbSidebar_Click(object sender, EventArgs e)
{
Business.Assets asset = new Business.Assets();
LinkButton btn = (LinkButton)(sender);
string[] arg = new string[2];
arg = btn.CommandArgument.ToString().Split(';');
int yourValue = System.Convert.ToInt32(arg[0]);
string breacrumbValue= arg[1];
phBreadcrumb.Controls.Add(new Literal() { Text = "<li>"+breacrumbValue+"</li>"});
repeaterAssets.DataSource = asset.FilterGridview(yourValue);
repeaterAssets.DataBind();
}
以下是DOM资源管理器向我展示的内容:
<ul>
<li>
<a class="submenuLink" id="MainContent_lvHardware_lbSidebar_0" href="javascript:__doPostBack('ctl00$MainContent$lvHardware$ctrl0$lbSidebar','')"><i class="glyphicon glyphicon-menu-right leftNavIcon"></i>Desktop CPU</a>
</li>
</ul>
答案 0 :(得分:0)
<ul id="leftNavigation">
<li id="liHardware" runat="server"><a href="#"><i class="leftNavIcon"></i>Hardware</a>
<asp:ListView ID="lvHardware" runat="server">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<ul>
<li>
<asp:LinkButton ID="lbSidebar" runat="server" CssClass="submenuLink" OnClick="lbSidebar_Click" CommandArgument='<%#Eval("TableKey")+";"+Eval("TableValue")%>'><i class="glyphicon glyphicon-menu-right leftNavIcon"></i><%#Eval("TableValue")%></asp:LinkButton>
</li>
</ul>
</ItemTemplate>
</asp:ListView>
</li>
</ul>
</div>
代码背后的代码:
protected void lbSidebar_Click(object sender, EventArgs e)
{
Business.Assets asset = new Business.Assets();
LinkButton btn = (LinkButton)(sender);
string[] arg = new string[2];
arg = btn.CommandArgument.ToString().Split(';');
int yourValue = System.Convert.ToInt32(arg[0]);
string breacrumbValue= arg[1];
phBreadcrumb.Controls.Add(new Literal() { Text = "<li>"+breacrumbValue+"</li>"});
repeaterAssets.DataSource = asset.FilterGridview(yourValue);
repeaterAssets.DataBind();
liHardware.Attributes.Add("class","active");
}
我刚刚添加了一个将显示的类:在单击链接按钮时阻止li包装。
.active{display:block;}