ECMA Script : To delete a SharePoint 2010 list

 

<script language="ecmascript" type="text/ecmascript">

 

    var clientContext = null;

    var oWeb = null;

    var oListColl = null;

    var oList = null;

 

    function deleteList() {

 

        clientContext = new SP.ClientContext.get_current()

        oWeb = clientContext.get_web();

        oListColl = oWeb.get_lists();

        oList = oListColl.getByTitle('List1');

        oList.deleteObject();

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

    }

 

    function onQuerySucceeded() {

      

        alert("List deleted successfully");

    }

 

    function onQueryFailed(sender, args) {

        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

    }

 

</script>

<input id="btndeleteList" onclick="deleteList()" type="button" value="Delete the list"/>

Ebook Download
View all
Learn
View all