共用方式為


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)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class SPControl _
    Inherits Control _
    Implements IDesignTimeHtmlProvider, IDesignerEventAccessor
'Usage
Dim instance As SPControl
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, 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.CTFieldRefs
      Microsoft.SharePoint.WebControls.CTFieldRefsContainer
      Microsoft.SharePoint.WebControls.CustomJSUrl
      Microsoft.SharePoint.WebControls.DelegateControl
      Microsoft.SharePoint.WebControls.FormattedString
      Microsoft.SharePoint.WebControls.FormDigest
      Microsoft.SharePoint.WebControls.GroupPermissions
      Microsoft.SharePoint.WebControls.IEVersionMetaTag
      Microsoft.SharePoint.WebControls.LanguageSpecificContent
      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.PageStateActionButton
      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.SearchArea
      Microsoft.SharePoint.WebControls.SoapDiscoveryLink
      Microsoft.SharePoint.WebControls.SPCalendarNavigator
      Microsoft.SharePoint.WebControls.SPNoScript
      Microsoft.SharePoint.WebControls.SPPageStateControl
      Microsoft.SharePoint.WebControls.SPShortcutIcon
      Microsoft.SharePoint.WebControls.TemplateBasedControl
      Microsoft.SharePoint.WebControls.Theme
      Microsoft.SharePoint.WebControls.UIVersionedContent
      Microsoft.SharePoint.WebControls.ULSClientConfig
      Microsoft.SharePoint.WebControls.UrlRedirector
      Microsoft.SharePoint.WebControls.ViewSearchForm
      Microsoft.SharePoint.WebControls.ViewSelector
      Microsoft.SharePoint.WebControls.WarnOnUnsupportedBrowsers
      Microsoft.SharePoint.WebControls.WelcomePageTransfer