天天看点

如何使用asp.net 1.1中的webcontrol中的TreeView

第一步

修改web.config

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

 <configsections>

        <section name="microsoftwebcontrols" type="system.configuration.namevaluesectionhandler, system, version=1.0.5000.0, culture=neutral, publickeytoken=b77a5c561934e089" />   

</configsections>

 <microsoftwebcontrols>

 <add key="commonfiles" value="treepath" />

</microsoftwebcontrols>

  <system.web>

...................................

第二步,在想使用此控件的页面加入以下语句

<%@ import namespace="microsoft.web.ui.webcontrols"%>

<%@ register tagprefix = "iecontrols"

    namespace="microsoft.web.ui.webcontrols"

    assembly="microsoft.web.ui.webcontrols"

%>

 <iecontrols:treeview id="tvbasic" autoselect="false" shoplus="true" showlines="true" expandlevel="2"

    runat="server">

    <iecontrols:treenode text="root" expanded="true">

     <iecontrols:treenode text="node1" expanded="true">

      <iecontrols:treenode text="node11"></iecontrols:treenode>

     </iecontrols:treenode>

    </iecontrols:treenode>

   </iecontrols:treeview>

第三

将控件的这个属性改为空,(转到设计页面右击控件->属性)systemimagespath

第四,

在网站中新建一个treepath目录

将c:/program files/ie web controls/build/runtime下的文件拷入其中

第五,

写代码

 this.tvbasic.nodes.clear();

 treenode tn=new treenode();

 tn.text="nodes level1";

 tvbasic.nodes.add(tn);

 treenode tn2=new treenode();

 tn2.text="level2";

 tvbasic.nodes.add(tn2);

 treenode tn3=new treenode();

 tn3.text="level3";

 tn.nodes.add(tn3);

其它可见