Click to Rate and Give Feedback
Community Content
In this section
Statistics Annotations (1)
Collapse All/Expand All Collapse All
This page is specific to
The 2007 product release

Other versions are also available for the following:
SPRegionalSettings Class (Microsoft.SharePoint)
Represents regional settings that are used on the server that is running Windows SharePoint Services.

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Visual Basic (Declaration)
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
Public Class SPRegionalSettings
Visual Basic (Usage)
Dim instance As SPRegionalSettings
C#
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
public class SPRegionalSettings

Use the RegionalSettings property of the SPWeb class to return an SPRegionalSettings object that represents the regional settings for a Web site. You can return the same regional settings through the SPRegionalSettings constructor. Use the RegionalSettings property of the SPUser class to return an SPRegionalSettings object that represents the regional settings for a user.

If you modify the locale of a Web site through the Locale property and call the Update method to apply changes, the following properties on the existing Web site object reflect the original regional settings, not the new ones. To retrieve the new settings, create a new Web site object, which you can do by using the OpenWeb method, to access the properties for regional settings (for example, newWebSiteObject.RegionalSettings.DateFormat).

The following code example creates a subsite within a site collection, modifies the date format that is used in regional settings for the new Web site, and then displays the new setting.

Visual Basic
Dim siteCollection As New SPSite("http://localhost")
Try
    Dim rootWebSite As SPWeb = siteCollection.RootWeb
    Dim newSubSite As SPWeb = rootWebSite.Webs.Add("MySite")
    newSubSite.Locale = CultureInfo.CreateSpecificCulture("ja-JP")

    newSubSite.Update()

    Dim webSite As SPWeb = siteCollection.OpenWeb(rootWebSite.Webs("MySite").ID)
    Response.Write(webSite.RegionalSettings.DateFormat)

    rootWebSite.Dispose()
    newSubSite.Dispose()
    webSite.Dispose()
Finally
    siteCollection.Dispose()
End Try
C#
using (SPSite oSiteCollection = new SPSite("http://localhost"))
{
    SPWeb oWebsiteRoot = oSiteCollection.RootWeb;
    SPWeb oWebsiteNew = oWebsiteRoot.Webs.Add("MySite");
    oWebsiteNew.Locale = CultureInfo.CreateSpecificCulture("ja-JP");

    oWebsiteNew.Update();

    SPWeb oWebsiteCurrent = oSiteCollection.OpenWeb(oWebsiteRoot.Webs["MySite"].ID);
    Response.Write(oWebsiteCurrent.RegionalSettings.DateFormat);
    oWebsiteRoot.Dispose();
    oWebsiteNew.Dispose();
    oWebsiteCurrent.Dispose();
}
NoteNote:

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Best Practices: Using Disposable Windows SharePoint Services Objects.

System.Object
  Microsoft.SharePoint.SPRegionalSettings
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker