用户自定义控件代码如下:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.IO;
namespace EWFS.CL
{
public struct stuTreeNodes
{
public string strKey;
public string strDispVal;
public string strParentKey;
public string strJavaScriptCmd;
}
public struct stuTreeNodesIcons
{
public string strTreeCaptionIcon;
public string strTreeContentOpenIcon;
public string strTreeContentCloseIcon;
}
public struct stuTreePopMenu
{
public string strMenuItemImg;
public string strMenuItemText;
public string strMenuItemCmd;
}
[DefaultProperty("Text"),
ToolboxData("<{0}:TreeView runat=server></{0}:TreeView>")]
public class TreeView : System.Web.UI.WebControls.WebControl
{
private string m_TreeCaption; //标题
private stuTreeNodes[] m_stuTreeNodes; //节点内容
private stuTreeNodesIcons m_stuTreeNodesIcons; //节点图标
private string m_TreeChangedPostURL; //修改后的树传送的地址
private bool m_TreeAddDir;
private bool m_TreeRenDir;
private bool m_TreeDelDir;
private stuTreePopMenu[] m_stuTreePopMenu;
private string m_GotoID;
private bool m_TreeRootPopMenu;
private System.Data.DataSet m_dsTreeNodes;
protected System.Web.UI.WebControls.Table TreeTable;
public string TreeGotoID //定位ID
{
get{return m_GotoID;}
set{m_GotoID=value;}
}
[Bindable(true),
Category("Appearance"),
DefaultValue(true)]
public bool TreeRootPopMenu
{
get{return m_TreeRootPopMenu;}
set{m_TreeRootPopMenu=value;}
}
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public bool TreeAddDir
{
get{return m_TreeAddDir;}
set{m_TreeAddDir=value;}
}
public bool TreeRenDir
{
get{return m_TreeRenDir;}
set{m_TreeRenDir=value;}
}
public bool TreeDelDir
{
get{return m_TreeDelDir;}
set{m_TreeDelDir=value;}
}
public stuTreePopMenu[] StuTreePopMenu
{
get{return m_stuTreePopMenu;}
set{m_stuTreePopMenu=value;}
}
public string TreeChangedPostURL
{
get{return m_TreeChangedPostURL;}
set{m_TreeChangedPostURL=value;}
}
public stuTreeNodesIcons StuTreeNodesIcons
{
get {return m_stuTreeNodesIcons;}
set {m_stuTreeNodesIcons = value;}
}
public stuTreeNodes[] StuTreeNodes
{
get
{
return m_stuTreeNodes;
}
set
{
m_stuTreeNodes=value;
}
}
public string TreeCaption
{
get
{
return m_TreeCaption;
}
set
{
m_TreeCaption = value;
}
}
/// <summary>
/// 获取节点内容
/// </summary>
public System.Data.DataSet dsTreeNodes
{
get{return this.m_dsTreeNodes;}
set
{
this.m_dsTreeNodes=value;
SetTreeNodes();
}
}
private void SetTreeNodes()
{
this.m_stuTreeNodes =new stuTreeNodes[m_dsTreeNodes.Tables[0].Rows.Count];
for(int i=0;i<m_dsTreeNodes.Tables[0].Rows.Count;i++)
{
this.m_stuTreeNodes[i].strKey=m_dsTreeNodes.Tables[0].Rows[i][0].ToString();
this.m_stuTreeNodes[i].strParentKey=m_dsTreeNodes.Tables[0].Rows[i][1].ToString()=="0"?"":m_dsTreeNodes.Tables[0].Rows[i][1].ToString();
this.m_stuTreeNodes[i].strDispVal=m_dsTreeNodes.Tables[0].Rows[i][2].ToString();
this.m_stuTreeNodes[i].strJavaScriptCmd=m_dsTreeNodes.Tables[0].Rows[i][3].ToString();
}
}
/// <sum