Export (0) Print
Expand All

SPRegionalSettings Class

Windows SharePoint Services 3

Represents regional settings that are used on the server that is running Windows SharePoint Services.

System.Object
  Microsoft.SharePoint.SPRegionalSettings

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

[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.

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.

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

Community Additions

ADD
Show:
© 2014 Microsoft