SP.List Class

Applies to: SharePoint Foundation 2010

Represents a list on a SharePoint Web site.

SP.List

Inherits

SP.SecurableObject Class

Remarks

The BrowserFileHandling, DataSource, EffectiveBasePermissions, HasUniqueRoleAssignments, IsAttachmentLibrary, OnQuickLaunch, SchemaXml, ValidationFormula and ValidationMessage properties are not included in the default scalar property set for this type.

Example

The following example creates an input button on an application page that creates a new discussion board list on the current web site.

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var list;
    function runCode() {
        var clientContext = new SP.ClientContext.get_current();

        if (clientContext != undefined && clientContext != null) {
            var web = clientContext.get_web();

            // Specify the properties of the new list.
            var listCreationInfo = new SP.ListCreationInformation();
            listCreationInfo.set_title('New Discussion Board');
            listCreationInfo.set_templateType(SP.ListTemplateType.discussionBoard);

            this.list = web.get_lists().add(listCreationInfo);

            clientContext.load(list);
            clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
        }
    }

    function onQuerySucceeded() {
        var result = ' Added Discussion Board: ' + this.list.get_title();
        alert(result);
    }

    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }

</script>

    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />

</asp:Content>

See Also

Reference

SP.List Methods

SP.List Properties

SP Namespace