Sharepoint By Dummies

See Also:

Putting the user’s name on an ASPX page

with one comment

One of the things we occaisionally have to do is to put the current user’s name onto the page they are viewing.   Usually this is just pretty cosmetic in nature,  just a courtesy.  For example if it’s a page related to a risk log that displays all risks owned by or assigned to that user rather than just calling it ‘My Risks’ we’d call it ‘[user’s name]’s Risks’.

In WSS 3.0 (aka Sharepoint 2007) this is fairly simple.  Just drop a dataview webpart onto the page, remove all but one column and strip out pretty much every displayable element then set a parameter to pick up the value from a Server Variable called CurrentUserName.  Then use an xsl:value-of select to display the parameter.  You land up with something like:

<xsl:param name="UserID">CurrentUserName</xsl:param>
<xsl:value-of select="$UserID"></xsl:value-of>

in the code view.  In Sharepoint 2010 we found that this doesn’t work, is displays nothing.  Eventually we discovered that in Sharepoint 2010 you have to manaully add a line to the Parameter Bingings area of the web part:

<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName" />

Not sure why (my boss thinks it’s cos without that the parameter doesn’t get processed until after page has rendered), but it seems to work.




Written by stephenboothuk

August 16, 2011 at 5:33 pm

Posted in Uncategorized

One Response

Subscribe to comments with RSS.

  1. […] from  controls a lot, mostly on filters for dataviews.  For an overview see my entry on putting the users name on an aspx page.  With this if you have a form on the same page (in the insert or edit template) you can […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Speeches I Would Have Given

What I would have said at conference

Blogging about dyspraxia, aiming to raise much needed awareness a bit at a time as well as hopefully helping others along the way.

David Hunt, PE... Mechanical Engineer on the loose!

VALUE = Creativity + Diverse Experience + Critical Thinking

Not Literally Productions

Comedy, parody, tutorials and more!


A personal blog about having Asperger's

Dementia and Elderly Care News

News and research of interest to people involved in Dementia and Elderly Care

Marc D Anderson's Blog

A Knowledge Management Zealot Speaks Out

Codeless Solutions for SharePoint

Bryon Wyly is a SharePoint Developer dedicated to finding the limits to out-of the-box SharePoint solutions

the political blog of gordon lyew

SharePoint Business Analyst

Just another weblog

%d bloggers like this: