Title: WalkThrough SharePoint WebPart ???? ?
1WalkThroughSharePoint WebPart ???? ?
Kaneboy MS MVP
?????WalkThrough?????????,????????? ??WalkThrough
??????????????Thanks.
2?WalkThrough???
- ???????????????????WebPart
- ?WebPart?????????????????
- ?WebPart???SharePoint Object Model
3????
- ??????WalkThrough SharePoint WebPart
???????VS.NET???WebPart?????,?WalkThrough????????
??
4???VS.NET?????WebPart??
?VS.NET?????Web Part Library??,??????SampleWebP
art,VS.NET??????????WebPart1?WebPart??(???????
SampleWebPart??)?
5?????? ListName
1??????? private String _sListName
"????" 2?????????? Browsable(true), Category(
"??"), DefaultValue(""), WebPartStorage(Storage.Pe
rsonal), FriendlyName("?????"), Description("?????
?????") public String ListName get return
_sListName set _sListName value
?????Attribute??? ?
Browsable ??????(????)??Panel?????
Category ?????
DefaultValue ???(?WebPart????????)???
WebPartStorage ??,Storage.Shared???????????,Storage.Personal???????????,Storage.None???
FriendlyName ?????Panel????
Description ?????Panel????
6?????? DisplayCount
1??????? private UInt32 _iDisplayCount
10 2?????????? Browsable(true), Category("??"
), DefaultValue(10), WebPartStorage(Storage.Person
al), FriendlyName("??????"), Description("????????
???") public UInt32 DisplayCount get
return _iDisplayCount set _iDisplayCount
value
7???????????????Method
private String GetListFiles() String result
"" if ((this.ListName ! null)
(this.ListName.Length gt 0))
SPQuery query new SPQuery()
query.Query "ltOrderBygtltFieldRef Name\"????\"
Ascending\"FALSE\" /gtlt/OrderBygt"
query.RowLimit this.DisplayCount
SPList list SPControl.GetContextWeb(this.Context
).Liststhis.ListName
foreach(SPListItem item in list.GetItems(query))
if (item.File ! null)
result "ltligtlta href'"
item.File.Url "'gt" item.File.Name "("
item.File.Author.Name ")" "lt/agtltbrgt"
return result
8????RenderWebPart()????
????RenderWebPart()?????????????GetListFiles()????
String?????? protected override void
RenderWebPart(HtmlTextWriter output)
output.Write(this.GetListFiles())
9???WebPart???????
1???WebPart(????.dwp??) 2??SPS?????WebPart(?SPS?
????web.config?????ltSafeControlgt?) 3??VS.NET????
.dll?????SPS????????bin??? 4??WebPart?????WebP
art? ????????????WalkThrough?????????
10????SPS???????
??SPS??????????web.config??,?????? lttrust
level"WSS_Minimal" originUrl""
/gt ????? lttrust level"WSS_Medium"
originUrl"" /gt
?? WebPart??????????????SharePoint Object
Model?(?????WSS SDK???SPS???????????????????),????
??WebPart?????,???? ? ???WebPart???????Policy?? ?
?WebPart?(.dll)????StrongName???GAC? ?
????SPS????????? ???????????,?????????WSS_Minimal?
??WSS_Medium(?????Full)?
11??????????WebPart??
1???????????????WebPart???????????????????,???????
??????
2???WebPart????????,???????????Web???
12??????????WebPart?? (?)
3???????Panel?,???????????????????????????????????
?????????,???WebPart??????????????????5(????????
???WebPart?DisplayCount??)?
4????????,????WebPart?????????,????????5????
13?? To Be Continue
????WalkThrough?,???????????WebPart????Code-Beh
ind????User Control ?(.cab)???Wppackager???WebPa
rt ?VS.NET???WebPart ???????????