一个ASP.NET 1.1下的可折叠菜单

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

源码:

None.gif namespace  LongYu.Utility
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
using System;
InBlock.gif    
using System.ComponentModel;
InBlock.gif    
using System.Data;
InBlock.gif    
using System.Text;
InBlock.gif    
using System.Web.UI;
InBlock.gif    
using System.Web.UI.WebControls;
InBlock.gif    
InBlock.gif
InBlock.gif    [ToolboxData(
"<{0}:TaskPanelBar runat=server></{0}:TaskPanelBar>")]
InBlock.gif    
public class TaskPanelBar : WebControl
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private StringBuilder builder1;
InBlock.gif        
string sRalativeCSSFolder;
InBlock.gif
InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
属性、事件#region 属性、事件
InBlock.gif
InBlock.gif        
private int _paddingLeft;
InBlock.gif        
private string _linkTarget;
InBlock.gif        [Category(
"TaskPanelBar"), DefaultValue("_self"), Bindable(true), Description("链接目标的窗口")]
InBlock.gif        
public string LinkTarget
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this._linkTarget;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this._linkTarget = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private Unit _width;
InBlock.gif        [Bindable(
false), Category("TaskPanelBar"), Description("设置或获取菜单栏的宽度"), DefaultValue("155px")]
InBlock.gif        
public override Unit Width
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this._width;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this._width = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _Folder="webparts/";
InBlock.gif        [Category( 
"高级属性" ) , Description( "获得或设置基本路径。" ) , BrowsableAttribute( true ),DefaultValue("webparts/")]
InBlock.gif        
public string BaseDir 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return _Folder;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set 
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                _Folder 
= value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif        
#endregion

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

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

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

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

InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif        
protected override void Render(HtmlTextWriter output)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif
InBlock.gif            builder1.Append(
"<div class=\"storeUserData\" id=\"oLayout\"></div>");
InBlock.gif            builder1.Append(
"</td>");
InBlock.gif            builder1.Append(
"</tr>");
InBlock.gif            builder1.Append(
"</table>");
InBlock.gif            output.Write(builder1.ToString());
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif 
InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
None.gif

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

 后台代码示例:
None.gif          protected  LongYu.Utility.TaskPanelBar MyTaskPanelBar;
None.gif    
None.gif        
private   void  Page_Load( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
for (int i=0;i<4;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MyTaskPanelBar.AddParentNode(
"标题");
InBlock.gif                MyTaskPanelBar.AddChildNode(
"内容","我是内容0","http://www.hszw.com");
InBlock.gif                MyTaskPanelBar.AddChildNode(
"内容1","我是内容1","http://www.hszw.com");
InBlock.gif                MyTaskPanelBar.EndParentNode();
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedBlockEnd.gif        }
显示效果:

图片,CSS,示例下载:
点击下载

转载于:https://www.cnblogs.com/longyu/archive/2007/06/02/a_WebMenu_Of_Aspnet_11.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值