从网上下的,稍微改进了一下,做成控件形式,给各位有需要的朋友,其中有很多不完善之处,且只能在IE下使用.

源码:

namespace LongYu.Utility
{
    
using System;
    
using System.ComponentModel;
    
using System.Data;
    
using System.Text;
    
using System.Web.UI;
    
using System.Web.UI.WebControls;
    

    [ToolboxData(
"<{0}:TaskPanelBar runat=server></{0}:TaskPanelBar>")]
    
public class TaskPanelBar : WebControl
    
{
        
private StringBuilder builder1;
        
string sRalativeCSSFolder;


        
属性、事件

        
public TaskPanelBar()
        
{
            
this._paddingLeft = 0;
            sRalativeCSSFolder 
= _Folder; 

            builder1 
= new StringBuilder();
            builder1.AppendFormat(
"<table cellpadding=\"0\" cellspacing=\"0\" width=\"{0}\" id=\"{1}\" class=\"clsPartContainer\" border=\"0\" bgcolor=\"#f0e8d8\">"this.Width, this.ClientID);
            builder1.Append(
"<LINK REL='stylesheet' TYPE='text/css' HREF='" + sRalativeCSSFolder + "/WebParts.css'></LINK>");
            builder1.Append(
"<tr>");
            builder1.Append(
"<td valign=\"top\" bgcolor=\"#f0e8d8\">");
        }


        
public void AddChildNode(string text,string description,string url)
        
{
            
            
this.builder1.AppendFormat("<UL style=\"padding-left:  {4}px;\"><LI><a href=\"{0}\" title=\"{1}\" target=\"{2}\">{3}</a></LI></UL>"new object[] { url, description, this.LinkTarget, text, this._paddingLeft });

        }


        
public void AddParentNode(string text)
        
{
            builder1.Append(
"<table cellpadding=\"0\" cellspacing=\"0\" class=\"clsPart\" width=\"150\" border=\"0\">");
            builder1.Append(
"<tr>");
            builder1.Append(
"<td class=\"clsPartHead\" valign=\"top\" align=\"left\" height=\"19\" width=\"15\">");
            builder1.Append(
"<img class=\"clsPartHead\" src=\"" + sRalativeCSSFolder + "/Images/gripblue.gif\" height=\"19\" width=\"15\">");
            builder1.Append(
"</td>");
            builder1.Append(
"<td class=\"clsPartHead\" valign=\"middle\" align=\"left\" width=\"115\">");
            builder1.AppendFormat(
"<b class=\"clsPartHead\">{0}</b>", text);
            builder1.Append(
"</td>");
            builder1.Append(
"<td class=\"clsPartRight\" valign=\"top\" align=\"right\" height=\"19\" width=\"25\" title=\"\u663e\u793a/\u9690\u85cf\">");
            builder1.Append(
"<img class=\"clsMinimize\" src=\"" + sRalativeCSSFolder + "/Images/downlevel.gif\" height=\"19\" width=\"25\">");
            builder1.Append(
"</td>");
            builder1.Append(
"</tr>");
            builder1.Append(
"<tr>");
            builder1.Append(
"<td colspan=\"3\">");
            builder1.Append(
"<table bgcolor=\"#f0e8d8\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
            builder1.Append(
"<tr>");
            builder1.Append(
"<td bgcolor=\"#6699cc\" colspan=\"1\" width=\"1px\" valign=\"top\"><div style=\"margin:1px;padding:0px;\"></div>");
            builder1.Append(
"</td>");
            builder1.Append(
"<td width=\"145\" colspan=\"2\" bgcolor=\"#f5f5f5\" valign=\"top\">");
            builder1.Append(
"<div class=\"PartContent\">");
            
        }


        
public void EndParentNode() 
        
{
            builder1.Append(
"</div>");
            builder1.Append(
"</td>");
            builder1.Append(
"<td bgcolor=\"#6699cc\" colspan=\"1\" width=\"1px\" valign=\"top\"><div style=\"margin:1px;padding:0px;\"></div>");
            builder1.Append(
"</td>");
            builder1.Append(
"</tr>");
            builder1.Append(
"<tr>");
            builder1.Append(
"<td bgcolor=\"#6699cc\" colspan=\"3\" height=\"1\" valign=\"top\"><div style=\"margin:1px;padding:0px;\"></div>");
            builder1.Append(
"</td>");
            builder1.Append(
"</tr>");
            builder1.Append(
"</table>");
            builder1.Append(
"</td>");
            builder1.Append(
"</tr>");
            builder1.Append(
"</table>");
        }




        
protected override void Render(HtmlTextWriter output)
        
{

            builder1.Append(
"<div class=\"storeUserData\" id=\"oLayout\"></div>");
            builder1.Append(
"</td>");
            builder1.Append(
"</tr>");
            builder1.Append(
"</table>");
            output.Write(builder1.ToString());
        }


 


    }

}



在页面里应用:
<%@ Register TagPrefix="cc1" Namespace="LongYu.Utility" Assembly="LongYu.Utility" %>
<cc1:TaskPanelBar id="MyTaskPanelBar" runat="server" BaseDir="webparts"></cc1:TaskPanelBar>

<%@ Register TagPrefix="webparts" Namespace="Hszw.Utility" Assembly="Hszw.Utility" %> 后台代码示例:
        protected LongYu.Utility.TaskPanelBar MyTaskPanelBar;
    
        
private void Page_Load(object sender, System.EventArgs e)
        
{
            
for (int i=0;i<4;i++)
            
{
                MyTaskPanelBar.AddParentNode(
"标题");
                MyTaskPanelBar.AddChildNode(
"内容","我是内容0","http://www.hszw.com");
                MyTaskPanelBar.AddChildNode(
"内容1","我是内容1","http://www.hszw.com");
                MyTaskPanelBar.EndParentNode();
            }


        }
显示效果:

图片,CSS,示例下载:
点击下载
<%@ Register TagPrefix="webparts" Namespace="Hszw.Utility" Assembly="Hszw.Utility" %><%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebMenu.ascx.cs" Inherits="Hszw.Web.Controls.BuildTree.WebMenu" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%><%@ Register TagPrefix="webparts" Namespace="Hszw.Utility" Assembly="Hszw.Utility" %><%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebMenu.ascx.cs" Inherits="Hszw.Web.Controls.BuildTree.WebMenu" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%><%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebMenu.ascx.cs" Inherits="Hszw.Web.Controls.BuildTree.WebMenu" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
posted on 2007-06-02 15:40  黑山小妖  阅读(1415)  评论(1编辑  收藏  举报