ie webControls treeview with xml 例子

 .aspx文件中的代码

   <form runat="server">
  <ie:TreeView runat="server">
    <ie:TreeNode runat="server" Text="ASP.NET Books" Expanded="True"
                   TreeNodeSrc="aspnetbooksTV.xml" />                  
  </ie:TreeView>
</form>

XML文件

<?xml version="1.0" encoding="UTF-8" ?>
- <TREENODES>
- <treenode text="Teach Yourself Active Server Pages 3.0 in 21 Days">
  <treenode text="Price - $34.95" />
- <treenode text="Authors">
  <treenode text="Mitchell" />
  <treenode text="Atkinson" />
  </treenode>
  <treenode text="Year Published - 2000" />
  </treenode>
- <treenode text="Designing Active Server Pages">
  <treenode text="Price - $29.95" />
- <treenode text="Authors">
  <treenode text="Mitchell" />
  </treenode>
  <treenode text="Year Published - 2000" />
  </treenode>
- <treenode text="ASP.NET: Tips, Tutorials, and Code">
  <treenode text="Price - $34.95" />
- <treenode text="Authors">
  <treenode text="Mitchell" />
  <treenode text="Mack" />
  <treenode text="Seven" />
  <treenode text="Walther" />
  <treenode text="Anders" />
  <treenode text="Nathan" />
  <treenode text="Wahlin" />
  </treenode>
  <treenode text="Year Published - 2001" />
  </treenode>
- <treenode text="Programming ASP.NET">
  <treenode text="Price - $19.95" />
- <treenode text="Authors">
  <treenode text="Liberty" />
  <treenode text="Hurwitz" />
  </treenode>
  <treenode text="Year Published - 2002" />
  </treenode>
  </TREENODES>
 来自:http://aspnet.4guysfromrolla.com/demos/TreeViewBinding1.aspx

IE webcontrols

02-09

我用.net2003,下载了别人做的东西,装到了自己的机子上想试试,他要求安装IE webcontrols,我下载了一个安了,但还是不能用,出现以下错误信息.并且在我自己用这些组件时也不能正常使用,能通过调试,但是不能正常显示,只是简单的显示一些文本,没有树状结构或是莱单结构,请帮忙看一下怎么弄,谢谢!!rnrnrnrn“/HRAdmin”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrn分析器错误 rn说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。 rnrn分析器错误信息: 找到的名为“Microsoft.Web.UI.WebControls”的程序集清单定义与程序集引用不匹配。rnrn源错误: rnrnrn行 1: <%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral,PublicKeyToken=a739351522ccc560 " %>rn行 2: <%@ Page language="c#" Codebehind="Menu.aspx.cs" AutoEventWireup="false" Inherits="HRAdmin.USL.Menu" %>rn行 3: rn rnrn源文件: D:\HRAdmin\USL\Menu.aspx 行: 1 rnrn程序集加载跟踪: 下列信息有助于确定程序集“Microsoft.Web.UI.WebControls”无法加载的原因。rnrn=== Pre-bind state information ===rnLOG: DisplayName = Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=a739351522ccc560rn (Fully-specified)rnLOG: Appbase = file:///D:/HRAdminrnLOG: Initial PrivatePath = binrnCalling assembly : (Unknown).rn===rnrnLOG: Publisher policy file is not found.rnLOG: No redirect found in host configuration file (C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet.config).rnLOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.rnLOG: Post-policy reference: Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=a739351522ccc560rnLOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/hradmin/a7393515/22ccc560/Microsoft.Web.UI.WebControls.DLL.rnLOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/hradmin/a7393515/22ccc560/Microsoft.Web.UI.WebControls/Microsoft.Web.UI.WebControls.DLL.rnLOG: Attempting download of new URL file:///D:/HRAdmin/bin/Microsoft.Web.UI.WebControls.DLL.rnWRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKENrnrn rnrnrn--------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:1.1.4322.2300; ASP.NET 版本:1.1.4322.2300

分享:IE Webcontrols Treeview的一个bug及修正

02-25

首先感谢思归指点了我如何重用Treeview这个Microsoft IE Webcontrol。相关内容请参见http://community.csdn.net/Expert/TopicView.asp?id=3365114rnrn  IE webcontrol可以单独用于html文件中,也可以用于web form的.net 程序;rn  对于后者,使用中可以通过编程加入节点,也可以绑定;rn  对于后者,绑定的时候,可以帮定一个xml格式的字符串,也可以绑定一个xml文件,只要向Treeview控件的TreeNodeSrc属性赋值;rn  对于后者,有两种可能,一种是绑定到一个已经存在于硬盘的xml文件,或者说TreeNodeSrc的值设定为"...../foo.xml"上、另一种则是先创建一个aspx页面动态产生xml格式的输出,绑定到这个页面。rn  对于后者,会产生错误。rnrn  原因是,Treeview控件其实有两个地方可以绑定,或者说,解析数据源产生树的结构,一是在Server Side,一是在Browser Side。在Treeview控件Render的过程中,如果发现TreeNodeSrc是一个地址,它就会试图读这这个地址的内容,然后解析,并显式的写到web页面的输出中,这里会产生错误。rnrn  我的解决方法是,定义一个扩充的属性TreeNodeSrcA,它不在server端被解析,而是原封不动的写到Browser side,然后Treeview的htc再读取TreeNodeSrcA指向的url的内容,并解析。rnrn  具体步骤如下:rnrn一、在Treeview的源程序treeview.cs文件的rnrnpublic class TreeView : BasePostBackControlrnrn的部分加入这样一段rnrnrn/// rn/// Url of the xml file to import as the TreeNode content of the tree, Browser Side Bindingrn/// rn[rnCategory("Data"),rnDefaultValue(""),rnPersistenceMode(PersistenceMode.Attribute),rnResDescription("TreeNodeSrcA"),rn]rnpublic string TreeNodeSrcArnrn getrn rn object str = ViewState["TreeNodeSrcA"];rn return ((str == null) ? String.Empty : (string)str);rn rn setrn rn ViewState["TreeNodeSrcA"] = value;rn rnrnrn它的作用是定义一个叫TreeNodeSrcA的属性。rnrn二、在Treeview的源程序treeview.cs文件的rnrnprotected override void RenderUpLevelPath(HtmlTextWriter output)rnrn方法中加入这样一段rnrnif (TreeNodeSrcA != String.Empty)rn output.AddAttribute("treeNodeSrcA", TreeNodeSrcA);rnrn它的作用是如果TreeNodeSrcA属性非空则写到web页面的输出中。rnrn三、编译生成dll文件并引用rnrn四、在Treeview的脚本文件treeview.htc的相应位置分别加入:rnrnrnrnvar prop_treeNodeSrcA = null;rnrnfunction getTreeNodeSrcA()rnrn return prop_treeNodeSrcA;rnrnrnfunction setTreeNodeSrcA(value)rnrn if (prop_treeNodeSrcA != value)rn rn prop_treeNodeSrcA = value;rn rnrnrn这是说明定义一个htc里的属性,设置变量来存放,并设置读写它的方法。rnrn五、在Treeview的脚本文件treeview.htc的function oncontentready()中,在rn if (treeNodeSrc != null)rn之前,加入:rn if (treeNodeSrcA != null)rn treeNodeSrc = treeNodeSrcA;rn这就保证了创建的时候,如果扩展属性treeNodeSrcA非空,就会用它来填补treeNodeSrc,这时Browser就会去读数据源并解析、绑定。rnrn【athossmth原创,转载请注明,谢谢】rn

没有更多推荐了,返回首页