Share via


SPScenarioContext.GetContext method

Static method to get the SPScenarioContext object associated with the specified page for the specified culture. If a context object does not yet exist, one is initialized and stored in the session-state object.

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

Syntax

'Declaration
Public Shared Function GetContext ( _
    page As Page, _
    culture As CultureInfo _
) As SPScenarioContext
'Usage
Dim page As Page
Dim culture As CultureInfo
Dim returnValue As SPScenarioContext

returnValue = SPScenarioContext.GetContext(page, _
    culture)
public static SPScenarioContext GetContext(
    Page page,
    CultureInfo culture
)

Parameters

Return value

Type: Microsoft.SharePoint.Administration.SPScenarioContext
Returns an SPScenarioContext object, newly initialized or retrieved from the session state.

Exceptions

Exception Condition
[ArgumentNullException]

Thrown when page or culture are a null reference (Nothing in Visual Basic).

[ArgumentException]

Thrown when culture is CultureInfo.InvariantCulture.

[SPException]

Thrown when page is not a valid page.

See also

Reference

SPScenarioContext class

SPScenarioContext members

Microsoft.SharePoint.Administration namespace