多级菜单CSS+DIV

 

 

 

 

html原型

多级菜单CSS+DIV View Code
dddddddd

C#下的一个递归方法实现

 

 

多级菜单CSS+DIV View Code
DataTable menuTable;
protected   void  Page_Load( object  sender, EventArgs e)
{ litMenu.Text 
=  BuildMenu(menuTable.Select( " ParetnId is null " ),  "" );}
///   <summary>
///  导航菜单by 赵波2011-3-28
///   </summary>
///
< param name = " drs "   />
///
< param name = " parentStr "   />
///   <returns></returns>
public   string  BuildMenu(DataRow[] drs,  string  parentStr)
{
System.Text.StringBuilder sb 
=   new  System.Text.StringBuilder();
string  childMenu  =   string .Empty;
sb.Append(
"
< ul > " );
      // ParetnId // AccessPath // AccessName
      foreach  (var q  in  drs)
     {
     childMenu 
=  BuildMenu(menuTable.Select( " ParetnId= "   +  q[ " id " ].ToString()), q[ " id " ].ToString());
     
if  (childMenu.Length  & gt;  9 )
     {
     
string  startCss  =   string .Format( " <!--[if lte IE 6]><a class='sub' href='#'>{0}
      < table >
         
< tr >
             
< td ><! [endif] --> " , q[ " AccessName " ].ToString());
              string  endCss  =   "  <!--[if lte IE 6]></td>
          </ tr >
     
</ table >
     
</ a ><! [endif] --> " ;
     sb.AppendFormat( "
      < li >< a href = " http://www.cnblogs.com/qq4004229/admin/%5C%22#%5C%22 "   class = " hide " > { 0 } </ a > { 2 }{ 1 }{ 3 } </ li >
     
" , q[ " AccessName " ].ToString(), childMenu, startCss, endCss);
     }
     
else
     {
     sb.AppendFormat(
"
      < li >< a href = " http://www.cnblogs.com/qq4004229/admin/%5C%22%7B1%7D%5C%22 " > { 0 } </ a ></ li >
     
" , q[ " AccessName " ].ToString(), q[ " AccessPath " ].ToString());
     }
     }
     sb.Append(
" </ul>
      " );
      return  sb.ToString();
     }

 

 

你可能感兴趣的:(css+div)