Click here to Skip to main content
12,998,712 members (125,607 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 16 Jan 2014

SharePoint - Get the Current User's Regional Settings

, 16 Jan 2014
Rate this:
Please Sign up or sign in to vote.
How to retrieve the current user's Regional Settings using SharePoint Designer


This article describes how to retrieve the Regional Settings of the current user using SharePoint Designer.  This tip is useful for those users that do not have the appropriate permissions to add custom .Net code to SharePoint and are forced to use only SharePoint Designer.  This is specifically useful when a user modifies their regional settings to those different than the site default.

In my case, I discovered this tip when I needed the ability to format dates (based on the Locale ID).


This code was tested in SharePoint 2007 and SharePoint Designer 2007.  To change your personal regional settings do the following:

  1. In SharePoint web UI, click on your name (top right).
  2. Click My Settings. 
  3. Click My Regional Settings
  4. Modify as required.

Using the code 

The only place I could find where the regional settings were stored, was in the GetList method in the Lists.asmx web service (  Thus, we will use XML Web Service (SharePoint:SoapDataSource).

In this example, I will be accessing the Locale ID, so that I can determine how to format the dates returned. 


A. Create the XML Web Service (SoapDataSource).

  1. Open the page that you wish to edit in SharePoint Designer.
  2. In the Data Source Library window, under the XML Web Services, click on Connect to a web service...  
  3. In the Source tab, add the following to the Service description location:  <your site url>/_vti_bin/Lists.asmx?WSDL  (where <your site url> is the url to your site)
  4. Click Connect Now 
  5. Under Operation, Select GetList
  6. Select listName and click Modify.
  7. In Value, type in the name of any list in your site.  Please note, that the permission settings for this list should be available to everyone.  Click OK. 
  8. Click OK.

B. Access the XML Web Service through a DataFormWebPart.   The easiest way to demonstrate this would be to follow these steps: 

  1. On the same page as step A, click into the Code page and place the cursor to where you would like the data displayed. 
  2. Go to the Data Source Library.  Click on the newly created service from A.  Click Show Data.
  3. This will open the Data Source Details window. 
  4. Scroll down where RegionalSettings is displayed, select all fields under RegionalSettings.  Click Insert Selected Fields as...    
  5. Click on Single Item View 
  6. This will insert a DataFormWebPart onto the page.  When viewed from Design view, it will look something like this.  

C.  Modify the DataFormWebPart to accommodate your requirements.  As an example, I have modified the code so that the current date is saved to a hidden field.  The date stored here will represent the current date based on the appropriate regional settings of the user.

<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="0" Title="List Title" __markuptype="vsattributemarkup" __WebPartId="{720D6BF3-073B-4E6F-AA4B-51802A4229F0}" id="g_720d6bf3_073b_4e6f_aa4b_51802a4229f0" pagesize="1" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><DataSources><SharePoint:SoapDataSource runat="server" id="SoapDataSource1" AuthType="None" WsdlPath="" SelectUrl="" SelectAction="" SelectPort="ListsSoap" SelectServiceName="Lists"><SelectCommand><soap:Envelope xmlns:soap=""><soap:Body><GetList xmlns=""><listName>Test List</listName></GetList></soap:Body></soap:Envelope></SelectCommand></SharePoint:SoapDataSource></DataSources><ParameterBindings><ParameterBinding Name="dvt_apos" Location="Postback;Connection"/><ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/><ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/><ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/><ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/></ParameterBindings><datafields>ddw1:Language,Language;ddw1:Locale,Locale;ddw1:AdvanceHijri,AdvanceHijri;ddw1:CalendarType,CalendarType;ddw1:Time24,Time24;ddw1:TimeZone,TimeZone;ddw1:SortOrder,SortOrder;ddw1:Presence,Presence;</datafields><XSL><xsl:stylesheet xmlns:soap="" xmlns:ddw1="" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="" xmlns:asp="" xmlns:__designer="" xmlns:xsl="" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"><xsl:output method="html" indent="no"/><xsl:decimal-format NaN=""/><xsl:param name="dvt_apos">'</xsl:param><xsl:param name="Today"/><xsl:template match="/"><xsl:call-template name="dvt_1"/></xsl:template><xsl:template name="dvt_1"><xsl:variable name="Rows" select="/soap:Envelope/soap:Body/ddw1:GetListResponse/ddw1:GetListResult/ddw1:List/ddw1:RegionalSettings"/><xsl:variable name="Locale" select="$Rows/ddw1:Locale"/><input type="hidden" id="formattedCurrentDateHDN" value="{ddwrt:FormatDate(string($Today), $Locale, 1)}"/></xsl:template></xsl:stylesheet></XSL></WebPartPages:DataFormWebPart>



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jay Guiang
Architect GuiangStar Corp
Canada Canada
.in the MS development game for 14+ years.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 17 Jan 2014
Article Copyright 2014 by Jay Guiang
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid