1

I want to fetch the SharePoint List in my Asp.net Application.How can I do using JavaScript or Jquery?

1
2

I suggest to use the SharePoint web services to access the SharePoint lists from your application (regardless what's the technology that you use) as the following:

  • Create a service reference to access SharePoint lists
  • Open or create a Visual Studio project.
  • In Solution Explorer, right-click the References node, and then click Add Service Reference.
  • In the Address box, type the URL to the target site and append /_vti_bin/ListData.svc. For example, the address for the site intranet.wingtip.com would be http://intranet.wingtip.com/_vti_bin/ListData.svc.
  • Change the default name in the Namespace box from ServiceReference1 to something more appropriate, such as WingtipSite.
  • Click OK to create proxy classes, including a data context and entity classes for the lists that you want to access.
  • Begin writing code against these proxy classes, which provide strongly typed access to the columns of SharePoint list items.

For more details check

You can also use SharePoint client-side object model (CSOM) by referencing Microsoft.SharePoint.Client.dll to your solution.

For basic operation check Complete basic operations using SharePoint 2013 client library code

0

To get a SharePoint list using javascript:

var siteUrl = '/sites/MySiteCollection'; <-- URL of the web containing the list you are interested in
var listName = 'Documents'; <-- Name of the list you are interested in
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle(listName);

By now you have the SharePoint-list. If you are interested in the list items, you can get them using a caml-query to select the items you want.

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' + 
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
var collListItem = oList.getItems(camlQuery);

You can read more about it here:

https://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx

https://msdn.microsoft.com/en-us/library/office/jj163201.aspx

2
  • This will not work from another domain than the SharePoint server – Robert Lindgren Feb 21 '17 at 15:13
  • Good point. Didn't think it through. Still possible though, if not so wise, by adding some headers. :) – RHamsund Feb 21 '17 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.