I want to display the name of the user that is currently logged in SharePoint 2010 on the form of my Custom List. Please help. Thanks in advance for your help.
var currentcontext = new SP.ClientContext.get_current(); var currentweb = currentcontext.get_web(); currentcontext.load(currentweb); var currentuser = currentweb.get_currentUser(); currentuser.retrieve(); currentcontext.load(currentweb); var loginName = currentuser.get_loginName();
(Full example available here http://www.learningsharepoint.com/2011/05/18/get-current-users-loginname-ecmascript-sharepoint-2010/) Depending on where exactly you want to do this, you could add an HTML element to the page and then using getElementById (of jQUery selectors - if you are already referencing it) to set its content to the return value.
You can use below control as well :
<wssuc:Welcome id="IdWelcome1" runat="server" EnableViewState="false" > </wssuc:Welcome>
If you want to have it in xsl of list form, you may need to register before:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wssuc="Microsoft.SharePoint.WebControls" >