Showing posts with label User Name. Show all posts
Showing posts with label User Name. Show all posts

Thursday, February 23, 2017

SharePoint 2010/2013 Display user information using ProfilePropertyLoader

Hi Folks,

This article talks about the best way to get the user profile properties on page.

Sometimes we come across the requirement asking to show the User related information on the page.
Generally we write code by accessing User Information list to get the User related data.

In such cases, rather than writing code SharePoint gives us the provision to read the User data.

SharePoint has something called "ProfilePropertyLoader" control which will be available in any SharePoint page which has the below register tag.

<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Follwing are the tags we need to add to the page inoder to read the current user Name and Email.

User Name
The first line below is needed to load and make the profile properties available.

<SPSWC:ProfilePropertyLoader runat="server"/>

<SPSWC:ProfilePropertyValue PropertyName="FirstName" ApplyFormatting="False" runat="server" ShowPrivate="True" PrefixBrIfNotEmpty="False"/>

<SPSWC:ProfilePropertyValue PropertyName="LastName" ApplyFormatting="False" runat="server" ShowPrivate="True" PrefixBrIfNotEmpty="False"/>

Email
<SPSWC:ProfilePropertyValue cssClass="loggedin" PropertyName="WorkEmail" ApplyFormatting="False" runat="server" ShowPrivate="True" PrefixBrIfNotEmpty="False"/>


Hope this helps...

RELATED POST: How to get current user info using jquery spservices



Popular Posts