这是ToolBar控件,是不是和Vs.Net的工具条很像啊?!,但他是B/S结构的是MSPLUS控件集中的一个。
如下:你可以直接写在标签里,来定义TOOLBAR和他的子项
<cc1:MenuItem Label="编辑项目" ID="X7">
<cc1:MenuItem Label="删除" ID="X10" LeftIcon="icon_delete" LeftIconOver="icon_delete_over"></cc1:MenuItem>
<cc1:MenuItem Image="gray"></cc1:MenuItem>
<cc1:MenuItem Label="显示成员 " ID="X11" LeftIcon="icon_listMembers" LeftIconOver="icon_listMembers_over"
Disable="true">
<cc1:MenuItem Label="新建" ID="X12" LeftIcon="icon_new" LeftIconOver="icon_new_over"></cc1:MenuItem>
<cc1:MenuItem Label="新建二" ID="X13" LeftIcon="icon_new" LeftIconOver="icon_new_over"></cc1:MenuItem>
</cc1:MenuItem>
</cc1:MenuItem>
<cc1:MenuItem Label="删除" ID="X10" LeftIcon="icon_delete" LeftIconOver="icon_delete_over"></cc1:MenuItem>
<cc1:MenuItem Image="gray"></cc1:MenuItem>
<cc1:MenuItem Label="显示成员 " ID="X11" LeftIcon="icon_listMembers" LeftIconOver="icon_listMembers_over"
Disable="true">
<cc1:MenuItem Label="新建" ID="X12" LeftIcon="icon_new" LeftIconOver="icon_new_over"></cc1:MenuItem>
<cc1:MenuItem Label="新建二" ID="X13" LeftIcon="icon_new" LeftIconOver="icon_new_over"></cc1:MenuItem>
</cc1:MenuItem>
</cc1:MenuItem>
同时你也可你直接用DataTable或Xml进行绑定。
protected MSPlus.Web.UI.WebControls.MSMenu MSMenu1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面]
MSMenu1.DataSource = Server.MapPath("NewMenuData.xml");
MSMenu1.DataBind();
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面]
MSMenu1.DataSource = Server.MapPath("NewMenuData.xml");
MSMenu1.DataBind();
}
<?xml version="1.0" encoding="utf-8"?>
<MSPlus>
<MenuConfig></MenuConfig>
<MenuData>
<MenuItem Label="File" ID="X1">
<MenuItem Label="New" ID="X2" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
<MenuItem Label="Open" LeftIcon="icon_open.gif" LeftIconOver="icon_open_over.gif">
<MenuItem Label="From Disk" ID="X3" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
</MenuItem>
</MenuItem>
<MenuItem Label="Edit" ID="X4">
<MenuItem Label="File" ID="X1"/>
<MenuItem Label="File" ID="X1"/>
<MenuItem Image="gray.gif"/>
<MenuItem Label="File" ID="X1"/>
<MenuItem Label="File" ID="X1">
<MenuItem Label="New" ID="X2" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
<MenuItem Label="Open" LeftIcon="icon_open.gif" LeftIconOver="icon_open_over.gif">
<MenuItem Label="From Disk" ID="X3" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif">
<MenuItem Label="File" ID="X1">
<MenuItem Label="New" ID="X2" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
<MenuItem Label="Open" LeftIcon="icon_open.gif" LeftIconOver="icon_open_over.gif">
<MenuItem Label="From Disk" ID="X3" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuData>
</MSPlus>
<MSPlus>
<MenuConfig></MenuConfig>
<MenuData>
<MenuItem Label="File" ID="X1">
<MenuItem Label="New" ID="X2" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
<MenuItem Label="Open" LeftIcon="icon_open.gif" LeftIconOver="icon_open_over.gif">
<MenuItem Label="From Disk" ID="X3" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
</MenuItem>
</MenuItem>
<MenuItem Label="Edit" ID="X4">
<MenuItem Label="File" ID="X1"/>
<MenuItem Label="File" ID="X1"/>
<MenuItem Image="gray.gif"/>
<MenuItem Label="File" ID="X1"/>
<MenuItem Label="File" ID="X1">
<MenuItem Label="New" ID="X2" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
<MenuItem Label="Open" LeftIcon="icon_open.gif" LeftIconOver="icon_open_over.gif">
<MenuItem Label="From Disk" ID="X3" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif">
<MenuItem Label="File" ID="X1">
<MenuItem Label="New" ID="X2" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
<MenuItem Label="Open" LeftIcon="icon_open.gif" LeftIconOver="icon_open_over.gif">
<MenuItem Label="From Disk" ID="X3" LeftIcon="icon_new.gif" LeftIconOver="icon_new_over.gif"/>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuItem>
</MenuData>
</MSPlus>
他可以支持无限层。支持子控件的属性和状态的保存。你可以在运行时去动态的增加和删除子项或修改子项的属性。
子项的事件通过冒泡的方法一层层的像上传递,你只需增加一个Click事件就行!
private void MSMenu1_MenuItemClick(object sender, MSPlus.Web.UI.WebControls.MenuItemClickEventArgs e)
{
Response.Write("Click Item Label:" + e.EventItem.Label);
}
{
Response.Write("Click Item Label:" + e.EventItem.Label);
}
今天正好是周未下班后去外面逛了逛,买了件白衬衫(我长的比较黑,但穿白色的到也挺神气的,呵呵)。逛的时间太长了,有点累了,过会还要看奥运的开幕式,实在没有体力再写下去了,关于ToolBar的更详细介绍我后要将继续写下去。
今天就先大概的介绍一个DataList和ToolBar,MSPlus中的其它控件我将在今后陆续的介绍给大家,希望大家能支持我!