Get the LoggedIn User ID from Sharepoint using Javascript
I had a task to create a silverlight application which can be inserted to a sharepoint webpart (Content Editor); Everything went fine, except getting the logged in user name in the sharepoint site.
It took a long time for me to find the solution, So I thought I can post it here so that it would be helpful for others
I used a javascript with the silverlight object to retrieve the user name
function GetSPUserId()
{
return _spUserId.toString();
}
_spUserId returns the ID; from this you can eaisly retrieve the user details;
To call this javascript in Silverlight application
string g_SPUserID = HtmlPage.Window.Invoke("GetSPUserId", null) as string;
The method GetSPUserId is written in the HTML/ASPX page
Comments
Post a Comment