Getting Started Building Web Parts in SharePoint 2010
I followed the instructions provided in Module 1: Getting Started Building Web Parts in SharePoint 2010 webcast. This webcast teaches the following:
| Quick Resource Box |
The following walkthrough assumes you have Sharepoint 2010 Foundation installed on your dev station. Otherwise consider following the steps outlined in Setting Up the Development Environment for SharePoint Foundation on Windows 7. Step-by-step Walkthrough
<%\@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %> <%\@ Assembly Name="Microsoft.Web.CommandUI, Version=14..." % <%\@ Register Tagprefix="SharePoint..." %> ... <%\@ Control Language="C#" AutoEventWireup="true..." %> <asp:TreeView ID="siteStructure" runat="server"> </asp:TreeView>
using Microsoft.SharePoint;
SPWeb thisWeb = null; try { TreeNode node; thisWeb = SPContext.Current.Web; node = new TreeNode(thisWeb.Title, null, null, thisWeb.Url, "_self"); siteStructure.Nodes.Add(node); TreeNode parentNode = node; 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) { addWebs(childWeb, parentNode); } } catch (Exception) { throw; } finally { thisWeb.Dispose(); }
private 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) { addWebs(childWeb, parentNode); }
Related Books |