Click here to Skip to main content
15,883,883 members
Articles / Web Development / ASP.NET

Exploring SharePoint 2010 Client Object Model Capabilities

Rate me:
Please Sign up or sign in to vote.
4.54/5 (29 votes)
5 Jan 2011CPOL21 min read 146.7K   1.6K   47  
This article talks about the powerful SharePoint 2010 Client Object Model Capabilities and various ways to utilize it.
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UIDemoUserControl.ascx.cs" Inherits="ClientOMUIActions.UIDemo.UIDemoUserControl" %>
<style type="text/css">
    .style1
    {
        height: 23px;
    }
    .style2
    {
        height: 25px;
    }
</style>
<script type="text/javascript">

    //Dialog opening 
    function OpenListDialog() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "/_layouts/ClientOMUIActions/ListCreationPage.aspx";
        options.width = 600;
        options.height = 160;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseListCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }

    function OpenAllListsDialog() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "/_layouts/ClientOMUIActions/ListViewerPage.aspx";
        options.width = 600;
        options.height = 500;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseListCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }

    function OpenDocLibDialog() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "/_layouts/ClientOMUIActions/DocumentLibraryCreationPage.aspx";
        options.width = 600;
        options.height = 160;        
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseDocLibCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }

    function OpenAsyncDialog() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "/_layouts/ClientOMUIActions/AsynchronusProcessing.aspx";
        options.width = 800;
        options.height = 700;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseDocLibCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }
    
    function OpenCAMLDialog() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "/_layouts/ClientOMUIActions/UsingCAMLQuery.aspx";
        options.width = 800;
        options.height = 700;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseDocLibCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }

    function OpenLINQDialog() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "/_layouts/ClientOMUIActions/UsingLINQQuery.aspx";
        options.width = 800;
        options.height = 700;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseDocLibCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }

    function OpenSilverlightDialog() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "/SitePages/SilverlightWebPartOM.aspx";
        options.width = 600;
        options.height = 400;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseDocLibCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }    

    var messageId;

    // Dialog callback 
    function CloseListCallback(result, target) {
        if (result === SP.UI.DialogResult.OK) {
            javascript: setTimeout('javascript:return true;', 8000); 
            messageId = SP.UI.Notify.addNotification("<img src='_layouts/images/loading.gif'> Creating list <b>" + target + "</b>..."); 

            //alert("OK was clicked!");
        }
        if (result === SP.UI.DialogResult.cancel) {
            //alert("Cancel was clicked!");
            SP.UI.Notify.addNotification("Operation was cancelled...", false, "", null); 
        }
    }

    function CloseDocLibCallback(result, target) {
        if (result === SP.UI.DialogResult.OK) {
            javascript: setTimeout('javascript:return true;', 8000);
            messageId = SP.UI.Notify.addNotification("<img src='_layouts/images/loading.gif'> Creating document library <b>" + target + "</b>...");

            //alert("OK was clicked!");
        }
        if (result === SP.UI.DialogResult.cancel) {
            //alert("Cancel was clicked!");
            SP.UI.Notify.addNotification("Operation was cancelled...", false, "", null);
        }
    }

</script>
<table bgcolor="#83BB00" border="0" cellpadding="3" cellspacing="3">
<tr>
<td colspan="4">
<b>Using Client Object Model in SharePoint 2010</b>
</td>
</tr>
<tr>
<td class="style1">
    &nbsp;</td>
<td class="style1">
</td>
<td class="style1">
    &nbsp;</td>
<td class="style1">
    &nbsp;</td>
</tr>
<tr>
<td>
    <strong>.NET MANAGED</strong></td>
<td>
    <strong>ECMASCRIPT</strong></td>
<td>
    <strong>SILVERLIGHT CLIENT</strong></td>
<td>
    &nbsp;</td>
</tr>
<tr>
<td>
    <a href="Javascript:OpenCAMLDialog();">Using CAML Query</a>
</td>
<td>
<a href="Javascript:OpenListDialog();">Create a List </a> 
</td>
<td>
    <a href="Javascript:OpenSilverlightDialog();">Using Asynchronus Client Object Model</a> </td>
<td>
    &nbsp;</td>
</tr>
<tr>
<td>
    <a href="Javascript:OpenLINQDialog();">Using LINQ with Queries</a></td>
<td>
<a href="Javascript:OpenDocLibDialog();">Create a Document Library </a> 
</td>
<td>
    &nbsp;</td>
<td>
    &nbsp;</td>
</tr>
<tr>
<td>
    <a href="Javascript:OpenAsyncDialog();">Asynchronus Processing</a></td>
<td>
    &nbsp;</td>
<td>
    &nbsp;</td>
<td>
    &nbsp;</td>
</tr>
</table>

<br />
<br />
<br />
<br />
<br />
 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
A SharePoint Kid playing in Kolkata, India.

Working with one of the leading software company and currently working with SharePoint technologies.

Enjoys Cricket, National & World Music.

Favourite band include Linkin Park, Beatles, Oasis, Match Box 20, Noori, Nirvana, Nickelback etc.

Comments and Discussions