我已经努力了好几天,并尝试了不同的HTML标签和javascript。但是我有这个左侧的滑块菜单,想要保留选定的项目并在回发后选择该项目的标题。我正在显示菜单代码和一些图片尝试过的当前javascript。感谢您的帮助,我的意思是帮助!!!
谢谢!
<div id="leftside-navigation" style="overflow:hidden;">
<ul style="overflow:hidden;">
<li>
<a href="#" id="dashboard"><i class="fa fa-dashboard"></i><span>Dashboard</span></a>
</li>
<li id="submenu" class="sub-menu">
<a href="javascript:void(0);" class="menu-heading" id="lnkCampaign" runat="server"><i class="fa fa-user-circle"></i><span>Campaigns</span><i class="arrow fa fa-angle-right pull-right"></i></a>
<ul>
<li><a href="#" class="submenus" runat="server" id="All_Activity" onserverclick="All_ActivityClick">Activity at a Glance<span class="badge badge-pill badge-success pull-right" style="margin-right: 10px;"><i class="fa fa-check"></i></span></a>
</li>
<li><a href="#" class="submenus" runat="server" id="New_Campaign" onserverclick="New_CampaignClick">Create a New Campaign<span class="badge badge-pill badge-success pull-right" style="margin-right: 10px;"><i class="fa fa-check"></i></span></a>
</li>
<li><a href="#" class="submenus" runat="server" id="Campaign_Alerts">Alerts & Notifications</a>
</li>
</ul>
</li>
<li class="sub-menu">
<a href="javascript:void(0);"><i class="fa fa-file-text"></i><span>Reports</span><i class="arrow fa fa-angle-right pull-right"></i></a>
<ul>
<li><a href="#">Employee Sign In List by Campaign</a>
</li>
<li><a href="#">All Campaign's / Employees Signed Summary (counts only)</a>
</li>
<li><a href="#">All Campaign's / Employees Signed Detail</a>
</li>
</ul>
</li>
<li class="sub-menu">
<a href="javascript:void(0);"><i class="fa fa fa-drivers-license"></i><span>User Maintenance</span><i class="arrow fa fa-angle-right pull-right"></i></a>
<ul>
<li><a href="#">Add a New User</a>
</li>
<li><a href="#">Unlock a User</a>
</li>
</ul>
</li>
<li class="sub-menu">
<a href="javascript:void(0);"><i class="fa fa fa-drivers-license-o"></i><span>My Profile</span><i class="arrow fa fa-angle-right pull-right"></i></a>
<ul>
<li><a href="#">Update Your Profile</a>
</li>
<li><a href="#">Change Your Password</a>
</li>
</ul>
</li>
</ul>
</div>
这是我尝试过的Javascript。
// Keeps the Selected Item Selected after postback
function setActive(menuItemID) {
var selector = '#leftside-navigation ul li ' + menuItemID;
$(selector).addClass('active');
}
然后在我后面的代码中尝试使用选定控件的ID进行此操作(我意识到此引用引用了选定控件而不是选定标题),但是它根本不起作用。
ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:setActive(All_Activity); ", True)
这是菜单关闭的图片: enter image description here
这是一张带有选定项目的图片(我希望它在选定并回发后保持这样的样子): enter image description here