Share via


SPControl Class

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.

Inheritance Hierarchy

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

<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 _
    Inherits Control _
    Implements IDesignTimeHtmlProvider, IDesignerEventAccessor

Dim instance As SPControl
[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

Examples

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPControl Members

Microsoft.SharePoint.WebControls Namespace

Inheritance Hierarchy

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.AlphaImage
      Microsoft.SharePoint.WebControls.BpScript
      Microsoft.SharePoint.WebControls.CssLink
      Microsoft.SharePoint.WebControls.CssRegistration
      Microsoft.SharePoint.WebControls.CustomJSUrl
      Microsoft.SharePoint.WebControls.DelegateControl
      Microsoft.SharePoint.WebControls.FormattedString
      Microsoft.SharePoint.WebControls.FormDigest
      Microsoft.SharePoint.WebControls.GroupPermissions
      Microsoft.SharePoint.WebControls.ListFormPageTitle
      Microsoft.SharePoint.WebControls.ListItemProperty
      Microsoft.SharePoint.WebControls.ListProperty
      Microsoft.SharePoint.WebControls.Navigation
      Microsoft.SharePoint.WebControls.OWSControl
      Microsoft.SharePoint.WebControls.OWSForm
      Microsoft.SharePoint.WebControls.PortalConnection
      Microsoft.SharePoint.WebControls.PreReleaseFeedback
      Microsoft.SharePoint.WebControls.ProjectProperty
      Microsoft.SharePoint.WebControls.RelatedTasks
      Microsoft.SharePoint.WebControls.ReturnLink
      Microsoft.SharePoint.WebControls.RobotsMetaTag
      Microsoft.SharePoint.WebControls.RssLink
      Microsoft.SharePoint.WebControls.ScriptLink
      Microsoft.SharePoint.WebControls.SoapDiscoveryLink
      Microsoft.SharePoint.WebControls.SPCalendarNavigator
      Microsoft.SharePoint.WebControls.TemplateBasedControl
      Microsoft.SharePoint.WebControls.Theme
      Microsoft.SharePoint.WebControls.UrlRedirector
      Microsoft.SharePoint.WebControls.ViewSearchForm
      Microsoft.SharePoint.WebControls.ViewSelector