Title: WalkThrough SharePoint WebPart ????
1WalkThroughSharePoint WebPart ????
Kaneboy MS MVP
2????
- ??? WebPart ?
- ??SPS??WebPart Page??????
- ?WebPart????(.dwp)?WebPart???(.dll)??
- ??ASP.NET Custom Control
3?WalkThrough???
- ???VS.NET??????WebPart
- ?????WebPart???SPS???
4??????ASP.NET User Control
?VS.NET??????Web??,????Web????,????????????????U
serControl? ??????UserControl?Code-Behind??(.asc
x.cs)?????,???????????(.ascx)???????(.ascx)????lt
_at_ Control gt??,?CodeBehind?Inherited?????,???
???????(.ascx.cs)???
???,???????????WebUserControl1.ascx?User
Control,???????Calendar???
5??????WebPart
1????????WebPart Templates for VS.NET,???? 2??VS.N
ET?????Web Part Library??(??????SampleWebPart)
,VS.NET?????????????Microsoft.SharePoint.WebPartPa
ges.WebPart?WebPart(?????WebPart1),?????RenderWe
bPart()??? 3??WebPart1?????????????????UserControl
??? private System.Web.UI.Control
_innerUserControl 4???WebPart1????CreateChildCont
rols()??,???????????UserControl protected
override void CreateChildControls() _innerUserC
ontrol this.Page.LoadControl("/bin/WebUserContro
l1.ascx") this.Controls.Add(_innerUserControl)
5??RenderWebPart()????????UserControl protected
override void RenderWebPart(HtmlTextWriter
output) this.EnsureChildControls() _innerUser
Control.RenderControl(output)
6????WebPart
??WebPart1.dwp,????XML????????
lt?xml version"1.0" encoding"utf-8"?gt ltWebPart
xmlns"http//schemas.microsoft.com/WebPart/v2"
gt ltTitlegtKaneboy's Sample WebPartlt/Titlegt ltDescr
iptiongtKaneboy's SampleLWebPart, Heihei!
)lt/Descriptiongt ltAssemblygtSampleWebPartlt/Assembl
ygt ltTypeNamegtSampleWebPart.WebPart1lt/TypeNamegt lt
!-- Specify initial values for any additional
base class or custom properties here.
--gt lt/WebPartgt
Title ???SPS?????? Description
???SPS???????? Assembly ?????dll??????(??.dll)
TypeName ???WebPart????(??Namespace)
7????WebPart
?SPS????????SPS???????????,??web.config?? ???????
??ltSafeControlsgt??,?????ltSafeControlgt???,?????
?SPS?????WebPart?????????????WebPart???????? ltSa
feControl Assembly"SampleWebPart"
Namespace"SampleWebPart" TypeName""
Safe"True" /gt ???????????????(.dwp)?????????
8????WebPart
???????WebUserControl1.ascx?????????SampleWebPa
rt.dll???SPS????????SPS?????????????bin???(????
???,???????)?
???,?????????C/Inetpub/wwwroot/bin????(?????SPS
?????????????)
9????WebPart
1??SPS??????????
2?????????WebPart??????(.dwp)??,???????
10????WebPart (?)
3??????,?????????WebPart??????????????????????,?
?WebPart??????????
4?????
11??To Be Continue
??,?????User Control????????????Code-Behind???? Y
es !