1
votes

I need to add items to a SharePoint list using client object model. The issue I am facing is: Suppose I am at a page whose URL is http'://sharepointserver:7575/details.aspx

I want to fetch this complete URL & Similarly I need to fetch the current page name also using client object model. Can someone please guide me Which properties I can use to achieve this as I don't have any idea about client object model coding?

Any help would be greatly appreciated..

1
Why do you need to get absolute path using client object model? You can use simple javascript to achieve that - window.location.href . - Yevgeniy.Chernobrivets
Also what do you mean by "current page name"? - Yevgeniy.Chernobrivets
Thank you Yevgeniy for the quick response..!! I will try using javascript as you have mentioned but the requirement is to use client object model only. so, please kindly suggest the procedure to achieve the same by CSOM if possible. As per the second doubt, If I navigate to any page in the SharePoint site, I need to fetch the current page name which I am currently watching. If I navigate to second page, I should be able to fetch the secondpage name. Thank you... - Bhargav
Well client object model for browser is based on javascript so i think you can use javascript :). As for the second question - i meant what property did you mean? Where do you see it? - Yevgeniy.Chernobrivets
Hi Yevgeniy..! Suppose I have a sharepoint site testing:7575 I then created two pages firstpage.aspx & secondpage.aspx in this site. Now, I navigated to testing:7575/firstpage.aspx So, on page load I need to fetch this name: firstpage.aspx and then if I navigate to testing:7575/secondpage.aspx I should fetch this name:secondpage.aspx from the url. Thank you for your continuous support :) - Bhargav

1 Answers

2
votes

Try to use window.location.href to get full request url and window.location.pathname.substring(window.location.pathname.lastIndexOf("/") + 1); to get page name.