Razor View, master page
Still not much to say, directly on the code
<ulclass= "Sidebar-menu">@for (int i = 0; I<mlist. Count; i++) {if (Mlist[i]. Fatherid== 0) {mclist= Getchild (Mlist[i]. ModuleID,mlist);<!--A collection of level two menus--> <Liclass= "TreeView"><ahref="#"><Iclass= "fa fa-folder-o"></I><span>@mList [i]. ModuleName</span><Iclass= "fa fa-angle-left pull-right"></I></a><!--level Menu - <ulclass= "Treeview-menu">@for (int j = 0; J<mclist. Count; J + +)//two-level loop {if (Mclist[j]. Fatherid== 41)//If it is CRM, enter this loop {Mslis T= Getchild (Mclist[j]. ModuleID,mlist); <!--A collection of level three menus--> <Li><ahref= "javascript:void (0);"Data-id= "@mCList [j]. ModuleID "><Iclass= "fa fa-share"></I>@mCList [j]. ModuleName<Iclass= "fa fa-angle-left pull-right"></I></a><!--Level Two menu - <ulclass= "Treeview-menu">@for (int k = 0; K<mslist. Count; k++)//Three-level menu loop {if (! String.IsNullOrEmpty (Mslist[k]. Roteurl)) {<li><ahref= "@Url. Content (Mslist[k]. Roteurl) [email protected][k]. ModuleID "Data-id= "@mSList [K]. ModuleID "><Iclass= "fa fa-circle-o"></I>@mSList [K]. ModuleName</a></Li> <!--Level Three menu -i++; } else { <Li><ahref= "javascript:void (0)"Data-id= "@mSList [K]. ModuleID "><Iclass= "fa fa-circle-o"></I>@mSList [K]. ModuleName</a></Li> <!--Level Three menu -i++; } } </ul> </Li>i++; } else//Not CRM then enter this { if (! String.IsNullOrEmpty (Mclist[j]. Roteurl)) {<Li><ahref= "@Url. Content (Mclist[j]. Roteurl) [email protected][j]. ModuleID "Data-id= "@mCList [j]. ModuleID "><Iclass= "fa fa-circle-o"></I>@mCList [j]. ModuleName</a></Li> <!--Level Two menu -i++; } else { <Li><ahref= "javascript:void (0);"Data-id= "@mCList [j]. ModuleID "><Iclass= "fa fa-circle-o"></I>@mCList [j]. ModuleName</a></Li> <!--Level Two menu -i++; } } } </ul> </Li> } } </ul>
Here's the point.
$.widget.bridge (' UIButton ', $.ui.button); var_url = $.geturlparam ("CID"); $(". Sidebar-menu li a"). each (function() {//leave the status of the menu open var_id = $ ( This). Data ("id")); if(_id = =_url) { $( This). Parent (). Parent (). Show (); } }); $(". Sidebar-menu li a"). Click (function () { $( This). AddClass (""); }) });
Ways to get Menu parameters
(function($) {$.geturlparam=function(name) {varReg =NewRegExp ("(^|&)" + name + "= ([^&]*) (&|$)");//constructs an object that contains a regular expression of the target parameter varr = Window.location.search.substr (1). Match (REG);//Match target Parameters if(r! =NULL) { returnUnescape (r[2]);//Return parameter Values}Else { return NULL; }}) (JQuery);
Seventh Bootstrap 3-level menu style, support for master pages left open