[英]Sharepoint custom Web Part
我從http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.webpartpages.webpart.aspx修改了以下代碼段:
public class WebPartBla : Microsoft.SharePoint.WebPartPages.WebPart
{
private ArrayList someList;
protected override void CreateChildControls()
{
someList = new ArrayList();
SPWeb myWeb = SPControl.GetContextWeb(this.Context);
foreach(SPList list in myWeb.Lists)
{
if (list.BaseTemplate == SPListTemplateType.Tasks)
{
someList(list.Description);
}
}
}
/// <summary>
/// Render this Web Part to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void RenderWebPart(HtmlTextWriter output)
{
string strHTML = "";
for (int i = 0; i < someList.Count; i++)
{
strHTML = strHTML + "The task " + someList.Description + "<BR><BR>";
}
output.Write(strHTML);
}
}
誰能幫我
基本上,您需要在同一台計算機上使用Visual Studio和SharePoint來進行任何開發。
創建一個空的SharePoint項目,然后將Webpart添加到項目中。 將您那里的代碼放入Webpart代碼文件中並構建解決方案(您需要指定本地SP的URL才能執行此操作)。 然后,您可以通過右鍵單擊菜單進行部署。 此構建的另一個組件是WSP文件,您可以將其提取並部署到其他共享點環境。
此處的renderWebPart方法允許您直接在代碼中為Webpart編寫HTML。 這里的另一個選擇是使用可視化Web部件。
這是一個很好的教程(帶有圖片),顯示了如何創建Webpart http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-建立並部署一個Web部件.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.