子网的Sharepoint Web部件 [英] Sharepoint Web Parts for Subsites

查看:91
本文介绍了子网的Sharepoint Web部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来像一个简单的问题,但我已经在网上搜索并没有找到一个简单的答案。

如果我在Sharepoint Server 2007(企业版)上有一个网站,我创建了一些新的子网站和工作区,是否有一个将显示所有子网站的Web部件?或者我是否必须为每个子网站手动添加单个链接到列表,然后通过webpart显示列表?

This seems like a simple question but I've trawled the net and not found a simple answer.

If I have a site on Sharepoint Server 2007 (Enterprise edition), and I create a few new subsites and workspaces, is there a web part that will show all subsites? Or do I have to add individual links manually for each of the subsites to a list and then display the list through a webpart?

推荐答案

您好Peter,

Hi Peter,

以下是我们的支持工程师提供的一些信息,可能有所帮助:

Here's some info from our support engineer that may help:

我正在研究这个问题。我找不到任何列出子网站的Out of the Box webpart。但是我为webpart编写了一个示例代码,它将执行相同的操作。我正在以压缩格式附加项目,并在电子邮件正文中列出代码。

========================= ===================================

使用 系统;

using System.Runtime.InteropServices;

使用 System.Web.UI;

使用 System.Web.UI.WebControls.WebParts;

使用 系统.Xml.Serialization;

使用 Microsoft.SharePoint;

使用 Microsoft.Sha rePoint.WebControls;

使用 Microsoft.SharePoint.WebPartPages;

namespace ListSubSites

{

[ Guid " e96ea212-f44b-4d16-886d-e8fe7d389a7a" ; )]

    [Guid("e96ea212-f44b-4d16-886d-e8fe7d389a7a")]

public < span style ="color:blue"> class ListSubSites:System.Web.UI.WebControls.WebParts.WebPart

    public class ListSubSites : System.Web.UI.WebControls.WebParts.WebPart

{

string output = " ;< table border = \" 0 \">" ;

        string output = "<table border=\"0\">";

< span style ="font-size:10pt; fon t-family:'Courier New'"> 受保护 覆盖 void CreateChildControls()

        protected override void CreateChildControls()

{

base .CreateChildControls();

            base.CreateChildControls();

SPSite site = new SPSite(" http:// pranab- sec / " );

            SPSite site = new SPSite("http://pranab-sec/");

< span style ="font-size:10pt; font-family:'Cour ier New'"> SPWeb web = site.OpenWeb();

SPWebCollection subSites = web.Webs;

foreach (SPWeb subSite in subSites)

            foreach (SPWeb subSite in subSites)

{

输出+ = "< tr>< td>< a href = \"" + subSite.Url + " \" />" + subSite.Title + "< / a>< / td>< / tr>" ;

                output += "<tr><td><a href=\"" + subSite.Url + "\"/>" + subSite.Title + "</a></td></tr>";

}

输出+ = "< / table>" ;

            output += "</table>";

}

protected 覆盖 void 渲染(HtmlTextWriter writer)

        protected override void Render(HtmlTextWriter writer)

{

// TODO :在这里添加自定义渲染代码。

EnsureChildControls();

writer.Write(输出);

}

}

} < span style ="font-size:10pt; color:black; font-family:'Verdana','sans-serif'">

============== =========================================

-brenda(ISV Buddy Team)

-brenda (ISV Buddy Team)


这篇关于子网的Sharepoint Web部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆