Visual Studio 2005 extensions for Windows SharePoint Services 3.0 を使った Web パーツの作成
このデモの内容 |
ここでは、Visual Studio extension for Windows SharePoint Services を使った Web パーツの作成とデバッグ等についてご紹介します。
デモでご紹介しているソースコード |
【Web パーツのクラス (C#) 】
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Web.UI.WebControls;
namespace SampleWebPart
{
[Guid("e65135c2-d34d-4711-a831-e8c5696b9315")]
public class SampleWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
public SampleWebPart()
{
this.ExportMode = WebPartExportMode.All;
}
Label label;
CheckBox chkbox;
protected override void CreateChildControls()
{
base.CreateChildControls();
label = new Label();
SPWeb site = SPControl.GetContextWeb(Context);
label.Text = "Hello " + site.CurrentUser.Name + ", Welcome to " + site.Title;
this.Controls.Add(label);
chkbox = new CheckBox();
chkbox.Text = "太字表示";
chkbox.AutoPostBack = true;
this.Controls.Add(chkbox);
}
protected override void OnPreRender(EventArgs e)
{
this.EnsureChildControls();
if (chkbox.Checked)
label.Font.Bold = true;
else
label.Font.Bold = false;
base.OnPreRender(e);
}
}
}
![](images/cc707258.top(ja-jp, MSDN.10).gif)このページのトップへ