Answered by:
How to use Client Object model in Javascript

Question
-
Hello,
How can I use SharePoint client Object model in javascript. I have a input form link to each list item. when user click on the link it will open a input form(ASPX page). I need to get the current site, list and current list item from Javascript. Appreciate your reply.
Thanks,
Wednesday, July 25, 2012 4:22 PM
Answers
-
Hi AlexMathew,
You can use HttpContext.Current.Request.Url.
Check this thread for other option:
http://stackoverflow.com/questions/1544268/sharepoint-get-the-full-url-of-the-current-page-in-code-behind
Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
- Marked as answer by Lhan Han Thursday, August 2, 2012 7:09 AM
Thursday, July 26, 2012 12:11 PM
All replies
-
Hi
You have lots of examples describing how to use the Javascript client object model on MSDN: http://msdn.microsoft.com/en-us/library/hh185015
Here's a small example that gets the current site:
var context = new SP.ClientContext.get_current(); var web = context.get_web(); context.load(web); context.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess), Function.createDelegate(this, this.ExecuteOnFailure)); function ExecuteOnSuccess(sender, args) { alert('Success'); } function ExecuteOnFailure(sender, args) { alert("Error"); }
Kind Regards Bjoern
Blog
- Edited by Bjoern H Rapp Wednesday, July 25, 2012 4:54 PM
Wednesday, July 25, 2012 4:49 PM -
Hi Bjoern,
How to pass the site in query string and read it from aspx code behind page. Appreciate your reply!.
Thanks,
Wednesday, July 25, 2012 6:08 PM -
Hi AlexMathew,
You can use HttpContext.Current.Request.Url.
Check this thread for other option:
http://stackoverflow.com/questions/1544268/sharepoint-get-the-full-url-of-the-current-page-in-code-behind
Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
- Marked as answer by Lhan Han Thursday, August 2, 2012 7:09 AM
Thursday, July 26, 2012 12:11 PM