2 out of 5 rated this helpful - Rate this topic

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)
[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);

System.Object
   System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
       Derived Classes
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.