Tag Info

Hot answers tagged

3

The simplest solution is to append ?web=1 at the and of file url Ex: https://server/site/lib/filename.ext?web=1


3

You can use JSOM by javascript like two different ways: Using sp.js _spPageContextInfo.userLoginName Or you could use REST function getCurrentUser() { var endpointUrl = _spPageContextInfo.webServerRelativeUrl + '/_api/web/currentuser'; return $.ajax({ url: endpointUrl, method: "GET", contentType: ...


2

There are many ways to get logged in user name SPWeb site = SPControl.GetContextWeb(Context); SPUser user = site.CurrentUser; string strUserName = user.LoginName; or you can use SPWeb web = SPControl.GetContextWeb(this.Context); string userName = web.CurrentUser.LoginName; or you also can use string userName = this.Context.User.Identity.Name;


1

You can obtain the file URL and concatenate with a constant as in the following code: function documentWebUrl(ctx) { var fileUrl = ctx.CurrentItem.FileLeafRef.FileUrl; ExecuteOrDelayUntilScriptLoaded(function () { var clientContext = new SP.ClientContext(); var web = clientContext.get_web(); ...


1

The problem was in the event being undefined. IE and Chrome are okay with it, but FF doesn't like it. In the last line, the code should be function(event){Button.OnClick(this, event)



Only top voted, non community-wiki answers of a minimum length are eligible