Showing posts with label _spPageContextInfo. Show all posts
Showing posts with label _spPageContextInfo. Show all posts

Wednesday, January 28, 2015

Understand _spPageContextInfo object in SharePoint

Introduction

While creating the app in SharePoint we are using JavaScript and Client side object model. In development of app, we would require some basic properties to handle our app, SharePoint provide the few properties with _spPageContextInfo object.

_ spPageContextInfo will provide the below properties

  •  webServerRelativeUrl
  •  webAbsoluteUrl
  • siteAbsoluteUrl
  • serverRequestPath
  • layoutsUrl
  • webTitle
  • webTemplate
  • tenantAppVersion
  • isAppWeb
  • webLogoUrl
  • webLanguage
  • currentLanguage
  • currentUICultureName
  • currentCultureName
  • env
  • nid
  • fid
  • clientServerTimeDelta
  • updateFormDigestPageLoaded
  • siteClientTag
  • crossDomainPhotosEnabled
  • webUIVersion
  • webPermMasks
  • pagePersonalizationScope
  • userId
  • userLoginName
  • systemUserKey
  • alertsEnabled
  • siteServerRelativeUrl
  • allowSilverlightPrompt
  • themedCssFolderUrl
  • themedImageFileNames

Implementation


You can also access this object in JavaScript model as

<script type=”text/javascript”>
var propertyValue = _spPageContextInfo.PropertyName
</script>

Example


Get current login user name

<script type=”text/javascript”>
var loginName = _ spPageContextInfo. userLoginName
alert(loginName)
</script>

The above example will show an alert of value current user login.
To check the properties and its value of _spPageContextInfo, browse a SharePoint web page and open its view source (HTML – right click on web page à view page source) and find text “spPageContextInfo”.

See below screen shot



SharePoint AI Innovations Reach General Availability

Microsoft continues to strengthen the foundation for AI-powered workplaces with the announcement that several SharePoint AI innovations are ...