DataCollection Class

Current information about Live Connect is now available in the Windows Live Developer Center. The information in the following sections is provided for legacy purposes only.

Represents a collection of Windows Live resources, such as a Contact or Profile.

Feature:  Microsoft.Live.Services
Namespace:  Microsoft.Live.Services

The JavaScript Library for Windows Live Messenger Connect is built by using the Microsoft Ajax Library. Microsoft Ajax exposes a type system that enables you to add object-oriented capabilities to your JavaScript code. To learn more about creating, instantiating, and deriving from classes, see Creating Custom Client Script by Using the Microsoft Ajax Library.

Microsoft.Live.Services.DataCollection = function();


A collection of items can be collection of contacts or profiles, for example. The type of item added must be of type LiveItem.

When you get an instance of DataContext from the App class and use its load or loadAll methods, the DataCollectionload method and options property support the resource load. In a typical scenario, you use the load methods of DataContext from the App class instead of the load method of the DataCollection class directly.

The following code example demonstrates how to get a ContactCollection, which is derived from DataCollection.

function signInCallback(signInCompletedEventArgs) {
    if (signInCompletedEventArgs.get_resultCode() != Microsoft.Live.AsyncResultCode.success) {
        alert("sign-in failed: " + Microsoft.Live.AsyncResultCode.toString(signInCompletedEventArgs.get_resultCode()));
    // Get datacontext.
    dataContext = Microsoft.Live.App.get_dataContext();
    dataContext.loadAll(Microsoft.Live.DataType.contacts, contactsLoaded);
function contactsLoaded(dataLoadCompletedEventArgs) {
    if (dataLoadCompletedEventArgs.get_resultCode() !== Microsoft.Live.AsyncResultCode.success) {
        alert("Contacts failed to load: " + dataLoadCompletedEventArgs.get_error().message);
    // Get a DataCollection that contains contacts.
    contactsCollection = dataLoadCompletedEventArgs.get_data();
    // Create a view of the collection
    contactsView = contactsCollection.get_view();

    contactsView.hasnextPage(function (hasNext) {
        if (hasNext) {
            // Take action if next page exists

Windows Live Messenger Connect

Supported in: 4.1

Internet Explorer 8.0, Internet Explorer 7.0, Internet Explorer 6.0, Firefox 3.6, Firefox 3.5, Firefox 3.0, Firefox 2.0, Firefox 1.5, Chrome 4.0, Chrome 3.0, Chrome 2.0, Chrome 1.0, Safari 4.0, Safari 3.0