SPWeb.SiteUsers property
取得屬於網站集合的所有使用者集合。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Property SiteUsers As SPUserCollection
Get
'用途
Dim instance As SPWeb
Dim value As SPUserCollection
value = instance.SiteUsers
public SPUserCollection SiteUsers { get; }
Property value
Type: Microsoft.SharePoint.SPUserCollection
SPUserCollection 物件,表示使用者。
Examples
下列程式碼範例使用SiteUsers屬性來傳回使用者的目前網站集合與使用者的顯示名稱的集合
這個範例要求using指示詞 (Imports Microsoft Visual Basic 中), Microsoft.SharePoint和Microsoft.SharePoint.Utilities命名空間。
Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website_URL")
Dim users As SPUserCollection = webSite.SiteUsers
For Each user As SPUser In users
Response.Write((SPEncode.HtmlEncode(user.Name) + "<BR>"))
Next
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
SPUserCollection collUsers = oWebsite.SiteUsers;
foreach (SPUser oUser in collUsers)
{
Response.Write(SPEncode.HtmlEncode(oUser.Name) + "<BR>");
}
}
注意事項 |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |