1

I'm new using Sharepoint and I have a question. When I try to use this code:

var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var myItems = '';
var i;

for (i in items)
{
myItems += '|' + items[i].id;
}

Get this:

the type or namespace ClientContext name does not exist in the namespace (are you missing an assembly reference)

Which reference or using sentence am I missing? Even when I type the SP and dot, there is nothing there that allows me to select a method or something. I use Visual Studio 2013 professional and SharePoint 2010. Thanks

1 Answer 1

0

The code snippet above is JavaScript code, you seem to need C# code. That's the root of your issues.

Search for CSOM examples instead of JSOM / JavaScript samples and you should be of to a good start

5
  • Thank you very much. I'll look for CSOM examples to get the objects in a SharePoint List. Thanks again. Commented Feb 17, 2016 at 19:31
  • Try this link (section about list items, first example in that section): msdn.microsoft.com/en-us/library/office/… Commented Feb 17, 2016 at 19:40
  • Very useful !!! I got another question after see those examples: I have only one using directive (using Microsoft.Sharepoint;), do I have to add another?, thank you very much for your help. Commented Feb 17, 2016 at 19:46
  • Are you writing a farm solution or something in an app? The code examples in the link is for an app, here as for classic server side code: msdn.microsoft.com/en-us/library/office/… Commented Feb 17, 2016 at 20:01
  • I'm writing a farm solution, i'll check the link. Thank you, Commented Feb 17, 2016 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.