SharePoint开发网站结构树视图
2014-04-26 11:46
274 查看
SharePoint开发网站结构树视图
1. 新建可视WebPart项目。2. 插入Treeview
3. 查看代码,输入以下代码片:
using System; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; namespace SiteStructure.VisualWebPart1 { public partial class VisualWebPart1UserControl : UserControl { protected void Page_Load(object sender, EventArgs e) { SPWeb thisWeb = null; TreeNode node; thisWeb = SPContext.Current.Web; // Add the Web's title node = new TreeNode(thisWeb.Title, null, null, thisWeb.Url, "_self"); //The Visual Web Part has a treeview control called siteStructure siteStucture.Nodes.Add(node); //Get a reference to the current node, so child nodes can be added TreeNode parentNode = node; //Iterate through the lists collection of the Web foreach (SPList list in thisWeb.Lists) { if (!list.Hidden) { node = new TreeNode(list.Title, null, null, list.DefaultViewUrl, "_self"); parentNode.ChildNodes.Add(node); } foreach (SPWeb childWeb in thisWeb.Webs) { //Call our own helper function for adding each child web to the tree addWebs(childWeb, parentNode); childWeb.Dispose(); } siteStucture.CollapseAll(); } } void addWebs(SPWeb web,TreeNode parentNode) { TreeNode node; node=new TreeNode(web.Title,null,null,web.Url,"_self"); parentNode.ChildNodes.Add(node); parentNode=node; foreach (SPList list in web.Lists) { if (!list.Hidden ) { node=new TreeNode(list.Title ,null,null,list.DefaultViewUrl,"_self"); parentNode.ChildNodes.Add(node); } } foreach(SPWeb childWeb in web.Webs) { //Call the addWebs() function from itself (i.e. recursively) //to add all child webs until there are no more to be added addWebs(childWeb,parentNode); childWeb.Dispose(); } } } }
4. 部署解决方案,插入Web部件到页面,效果图:
相关文章推荐
- SharePoint开发网站结构树视图
- MOSS2007开发Demo系列(1)——用TreeView显示SharePoint网站文件夹结构(SPFolder)
- iOS开发-------模拟团购网站(UITableView 表格视图)以及自定义cell
- sharepoint视图权限控制器二次开发
- 【大型网站开发系列第一篇】——网站结构层次
- SharePoint开发 - Excel数据导入到SharePoint自定义列表(数据视图方式)
- 关于移动网站网页的基本代码结构和一些移动网站开发建议
- SharePoint 2007图文开发教程(2)---使用SharePoint创建网站
- 关于移动网站网页的基本代码结构和一些移动网站开发建议
- 数据库内置视图或者表结构在开发中的使用场景
- 关于移动网站网页的基本代码结构和一些移动网站开发建议
- 【大型网站开发系列第二篇】——网站代码结构
- MOSS2007开发Demo系列(2)——用GridView显示SharePoint网站中SPList的数据(SPList)
- SharePoint 2013 图文开发系列之网站栏
- SharePoint开发——利用CSOM逐级获取O365中SharePoint网站的List内容
- Qt5开发学习之模型/视图结构(十)
- 网站开发中的文件存储 目录结构的探讨
- nodejs+express搭建电影网站之二 -----具体项目结构 开发环境的建立 测试页面流程跑通
- Sharepoint网站栏开发
- Magento开发教程 - 后台设置多个网站,商店和商店视图