SPControl Class
Windows SharePoint Services 3
Provides methods for getting or setting the context of the request and serves as the base server control from which other controls in the Microsoft.SharePoint.WebControls namespace derive.
Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
[DesignerAttribute(typeof(SPControlDesigner))] [SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] [AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] [AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class SPControl : Control, IDesignTimeHtmlProvider, IDesignerEventAccessor
The following code example returns both a site collection object and a site object.
[Visual Basic .NET] Dim siteCollection As SPSite = SPControl.GetContextSite(Context) Dim site As SPWeb = SPControl.GetContextWeb(Context) [C#] SPSite siteCollection = SPControl.GetContextSite(Context); SPWeb site = SPControl.GetContextWeb(Context);