在web开发中,好像不能使用MessageBox.

解决方案 »

  1.   

    树形结构用TreeView,
    如果从数据库取数据的话,用递归
    using System;
    using System.Collections;namespace SampleTree
    {
    public class TreeNode
    {
    #region The TreeNodeCollection class.
    public class TreeNodeCollection:ICollection
    {
    private TreeNode _owner=null;
    private ArrayList _innerList=new ArrayList(); public TreeNodeCollection(TreeNode owner)
    {
    this._owner=owner;
    }
    public TreeNode this[int index]
    {
    get{return (TreeNode)this._innerList[index];}
    set
    {
    if(value ==null)
    throw new ArgumentNullException();
    (this._innerList[index] as TreeNode)._parent=null;;
    value._parent=this._owner;
    this._innerList[index]=value;
    }
    }
    public bool IsSynchronized
    {
    get{ return this._innerList.IsSynchronized;}
    }
    public int Count
    {
    get{ return this._innerList.Count;}
    }
    public void CopyTo(Array array, int index)
    {
    this._innerList.CopyTo(array,index);
    }
    public object SyncRoot
    {
    get
    {
    return this._innerList.SyncRoot;
    }
    }
    public IEnumerator GetEnumerator()
    {
    return this._innerList.GetEnumerator();
    } public int Add(TreeNode value)
    {
    if(value ==null)
    throw new ArgumentNullException();
    value._parent=this._owner;
    return this._innerList.Add(value);
    } public void Insert(int index, TreeNode value)
    {
    if(value ==null)
    throw new ArgumentNullException();
    value._parent=this._owner;
    this._innerList.IndexOf(value,index);
    } public void RemoveAt(int index)
    {
    try
    {
    this[index]._parent=null;
    this._innerList.RemoveAt(index);
    }
    catch
    {
    }
    }
    public int IndexOf(TreeNode value)
    {
    return this._innerList.IndexOf(value);
    }
    public void Clear()
    {
    for(int i=0;i<this.Count;i++)
    {
    this[i]._parent=null;
    }
    this._innerList.Clear();
    }
    public bool Contains(TreeNode value)
    {
    return this._innerList.Contains(value);
    }
    }
    #endregion

    private TreeNode _parent=null;
    private string _value=null;
    private TreeNodeCollection _childNodes=null; public TreeNode(string value)
    {
    this._value=value;
    }
    public TreeNode ParentNode
    {
    get{return this._parent;}
    }
    public string Value
    {
    get{return this._value;}
    }
    public TreeNodeCollection ChildNodes
    {
    get
    {
    if(this._childNodes !=null) return this._childNodes;
    this._childNodes=new TreeNodeCollection(this);
    return this._childNodes;
    }
    }
    public bool IsRoot
    {
    get{return this.ParentNode==null;}
    }
    public bool IsLeaf
    {
    get
    {
    return this._childNodes==null || this._childNodes.Count==0;
    }
    }
    public string Location
    {
    get
    {
    string location=string.Empty;
    TreeNode treeNode=this;
    while(treeNode.ParentNode!=null)
    {
    treeNode=treeNode.ParentNode;
    location=treeNode.Value+@"|"+location;
    }
    return this.Location;
    }
    }
    }
    public class Tree
    {
    private TreeNode.TreeNodeCollection  _nodes=new TreeNode.TreeNodeCollection(null); public TreeNode.TreeNodeCollection Nodes
    {
    get{return this._nodes;}
    }
    public TreeNode SearchNode(string location)
    {
    string[] loc=location.Split(new char[]{'|'});
    if(loc.Length==0) return null;
    TreeNode treeNode=null;
    for(int i=0;i<this.Nodes.Count;i++)
    {
    if(this.Nodes[i].Value==loc[0])
    {
    treeNode=this.Nodes[i]; break;
    }
    }
    int c=1;
    while(treeNode!=null && c<loc.Length)
    {
    for(int i=0;i<treeNode.ChildNodes.Count;i++)
    {
    if(treeNode.ChildNodes[i].Value==loc[c])
    {
    treeNode=treeNode.ChildNodes[i];
    c++;
    }
    }
    treeNode=null;
    }
    return treeNode;
    }
    }
    }
      

  2.   

    Web下的对话框如下:
    1...Page.RegisterClientScriptBlock("你自己定义的注册字符",“你的脚本块”),在客户端
    将出现在<form>后。
    2...Response.Write("<script language=javascript>alert('dkgj');</script>");
    3..Response.Write("<script language = jscript>alert('" + 你的提示信息 + "')</script>");
      

  3.   

    简单的示例: //***********class treenode   ******************
    class TreeNode
    {
    protected int nodedata;

    public TreeNode(int a)
    {
    nodedata=a;
    }
    //default state nodedata=0
    public TreeNode()
    {
    nodedata=0;
    }
    public int NodeData
    {
    get
    {
    return nodedata;
    }
    set
    {
    nodedata = value;
    }
    }
    //abstract public void CopyTo(TreeNode t);
    }
    //***********class twaintreenode ***************
    class TwaintreeNode:TreeNode
    {
    protected TwaintreeNode  leftchild;
    protected TwaintreeNode rightchild; public TwaintreeNode()
    {
    //base.NodeData=a;
    leftchild=null;
    rightchild=null;
    }
    public TwaintreeNode(int a)
    {
    leftchild=null;
    rightchild=null;
    this.nodeData=a;
    }
    /*public TwaintreeNode GetLeftchild()
    {
    return leftchild;
    }
    public TwaintreeNode GetRightchild()
    {
    return rightchild;
    }*/
    public TwaintreeNode LeftChild
    {
    get
    {
    return leftchild;
    }
    set
    {
    leftchild = value;
    }
    }
    public  TwaintreeNode RightChild
    {
    get
    {
    return rightchild;
    }
    set
    {
    rightchild = value;
    }
    }
    public void CopyTo(TwaintreeNode t)
    {
    if(t==null)
    t = new TwaintreeNode();
    if(this==null) return;
    t.nodedata=this.nodedata;
    t.leftchild=this.leftchild;
    t.rightchild=this.rightchild;
    }
    public int nodeData
    {
    get
    {
    return this.NodeData;
    }
    set
    {
    this.NodeData = value;
    }
    }
    }
    //*************class findtwaintree**************
    class FindtwainTree
    {
    protected TwaintreeNode boot;
    private  int nodenum; //three types makefunction
    public FindtwainTree()
    {
    boot = null;
    nodenum=0;
    }
    public FindtwainTree( int b)
    {
    boot = new TwaintreeNode(b);
    nodenum++;
    }
    public FindtwainTree(TwaintreeNode b)
    {
    boot=b;
    nodenum++;
    } public TwaintreeNode Boot
    {
    get
    {
    return boot;
    }
    set
    {
    boot = value;
    }
    } //use twaintreenode make tree
    private void addNode(TwaintreeNode t,TwaintreeNode s)
    {
    if(t==null)
    {
    t=s;
    return ;
    }
    if(s.nodeData<=t.nodeData)
    addNode(t.LeftChild,s);
    if(s.nodeData>t.nodeData)
    addNode(t.RightChild,s); }
    // use data of twaintreenode make tree
    private void addNode(TwaintreeNode t,int a)
    {
    /*if(t==null)
    {
    t = new TwaintreeNode(a);
    return;
    }*/

    if(a<t.nodeData)
    {
    if(t.LeftChild==null)
    {
    t.LeftChild=new TwaintreeNode(a);
    return;
    }
    addNode(t.LeftChild,a);
    }
    if(a>=t.nodeData)
    {
    if(t.RightChild==null)
    {
    t.RightChild=new TwaintreeNode(a);
    return;
    }
    addNode(t.RightChild,a);
    }
    }
    public void AddNode(TwaintreeNode d)
    {
    if(boot==null)
    boot=d;
    else
    {
    addNode(boot,d);
    }
    nodenum++;
    }
    //build the tree using data of twaintreenode
    public void AddNode(int d)
    {
    if(boot==null)
    {
    boot = new TwaintreeNode(d);
    }
    else
    addNode(boot,d);
    nodenum++;
    }