is it possible to use Client Object Model in the application page (say in the head tag) present under layouts folder(example:xlviewer.aspx)?, to fetch the current logged-in username. OR do we have to create new application page via visual studio and deploy it?
Asked
Active
Viewed 144 times
1 Answers
1
Of course it is. But why do you want to use the Client Object Model? Also, don't overwrite or change any of the oob SharePoint pages in the Layouts folder.Just create your own and deploy it via a Solution.
The code you can use is :
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
lblUserName.Text = SPContext.Current.Web.CurrentUser.LoginName;
}
}
If you really need to use Client Object Model, read here: Get current user in Client Object Model with javascript?
- Use a SharePoint CustomAction to hide the out of the box option to edit the excel file and create a new CustomAction to go to your custom aspx Page.
- Use a HttpModule (Such as the redirector) to redirect requests for xlviewer.aspx to mycustomxlviewer.aspx
– Fox Feb 04 '14 at 08:38