Top Menu

Tuesday, March 15, 2011

SharePoint Client Object Model vs Server Object Model Classes

One of the new feature of SharePoint 2010 is the Client Object Model. By using Client Object Model, developers can build the applications which can talk to SharePoint without using WebServices and without deploying any server side code.

Following is the list of Client Object Model classes and their equivalent to Server Object Model classes:

Client Object ModelServer Object Model
ClientContextSPContext
SiteSPSite
WebSPWeb
ListSPList
ListItemSPListItem
FieldSPField


Example:
using Microsoft.SharePoint.Client;

private void SomeMethod()
{
  ClientContext clientContext = new ClientContext(siteUrl);
  Site siteCollection = clientContext.Site;
  Web site = clientContext.Web;
}

Ref: http://msdn.microsoft.com/en-us/library/ee857094(office.14).aspx

Friday, March 4, 2011

EMail as Primary Key in List

Problem:
I have been asked a question today from one of the developers in another team that he wants to create a user registration list where emial should be unique for every user. And if user add item with existing email then he should be informed.

Solution:
We know that this functionality does not exist in the OTB SharePoint list features. After googling a bit I found following excellent solution using JQuery:

URL: http://sharepointjavascript.wordpress.com/2009/11/23/sharepoint-lists-or-document-librarys-primary-key-in-selected-field/

Monday, January 24, 2011

Silverlight Application in SharePoint 2010

In my last post I have explained how to develop the Silverlight application using Visual Studio 2010. Then we deployed that application in SharePoint 2007 using Content Editor Webpart. In this post I will explain how to deploy the same application in SharePoint 2010 using Silverlight Webpart.

Note: Please click here for the Silverlight application development using Visual Studio 2010. This Hello World Silverlight application can be deployed on both SharePoint 2007 and 2010.

Deployment to SharePoint 2010
  1. Go to the SharePoint portal.

  2. Upload the SilverlightApp.xap to a document library.

  3. Create a sample webpart page.

  4. Open the page in Edit mode and from the ribbon select Editing Tools -> Insert -> Web Part.

  5. From categories select Media and Content -> Silverlight Web Part -> Add.


  6. Provide the URL of the SilverlightApp.xap file and hit OK.


  7. It should look like this

Pretty easy hah! =]

Wednesday, January 19, 2011

Silverlight Application for SharePoint 2007


The goal of this post is to guide the .NET developers to write a basic Silverlight 3 application using Visual Studio 2010 and then deploying it to SharePoint 2007. Trust me its pretty easy :).

Development with Visual Studio 2010
Following are the steps to develop a simple Silverlight 3 application using Visual Studio 2010:

  1. Launch Visual Studio 2010

  2. Select File -> New -> Project -> Silverlight Application and hit Ok.


  3. Uncheck Host the Silverlight Application in a new Web site and select OK. We don’t want to host our Silverlight application in a ASP.NET Web application rather we will host it in a simple HTML page. This HTML Page will get created by the project.

  4. Now you are ready to do the development on MainPage.xaml.

  5. Drop a Textbox(txtMessage) and a Button(btnGo) on MainPage.xaml from the Toolbox on the left.


  6. Double click on the button to get it’s click event handler and paste following code there:

  7. namespace SilverlightApp  
    {  
    public partial class MainPage : UserControl  
    {  
        public MainPage()  
        {  
            InitializeComponent();  
        }  
        private void btnGo_Click(object sender, RoutedEventArgs e)  
        {  
            MessageBox.Show(this.txtMessage.Text);  
        }  
    }  
    }  
    

  8. Go to bin folder and you will see a HTML file (In my case its SilverlightAppTestPage.html). Launch that HTML file and it should display your Silverlight application. Clicking the Go button should display the text entered in the Textbox.



Note: When Silverlight application is compiled, Visual Studio generates a XAP file (compiled silverlight application) which runs in a silverlight enabled browser. HTML page contains the object tag to load the Silverlight control which runs the Silverlight application.

Deployment to SharePoint 2010
Following are the steps to deploy the Silverlight application in to a SharePoint 2007 site:

  1. Goto a SharePoint portal.

  2. Upload the Silverlight.xap file in a document library.

  3. Create a test ASPX page and add a Content Editor Web Part on it.

  4. Paste following HTML object code in the ContentEditor Web Part:

  5. <object type="application/x-silverlight-2" width="600" height="200">
        <param name="source" value="SilverlightApp.xap"/>
        <param name="minRuntimeVersion" value="3.0.40818.0" />
        <param name="background" value="white" />
    </object>
    <iframe id="_sl_historyFrame" style="height:0px;width:0px;border:0px"></iframe>
    

  6. Make sure to change the parth of the XAP file from the document library.

  7. Exit the edit mode.

  8. The Silverlight application should be displayed in the test page.




Thanks for reading :).

Tuesday, November 2, 2010

View All XML Data via XSLT


Some times we have to debug the XSLT for a WebPart (which generates XML data as output e.g. Search Core Results WebPart in MOSS) to manipulate the results. The first step of XSLT debugging is to see if the generated XML is valid and have all the necessary data.

Following is the code XSLT snippit to display all the XML elements:





<xsl:copy-of select="*"/>





Monday, October 4, 2010

MOSS Development/Customization Training

In April 2010, my manager Pradeep Thekkethodi asked me to conduct a Microsoft Office SharePoint Server 2007 Development training to upgrade the skills of our colleagues with .NET experience. The idea was to quickly bring the developers up to the speed for SharePoint Development and Advance Customization with SharePoint Designer 2007 and Visual Studio 2008. This training was held in our company Orion Systems Integrators Inc. This training was attended by 12 professionals.

I joined hands with my colleague Pramod who is a SharePoint Architect and we came up with a following course outline:

Module 1: SharePoint Object Model – 2 Hrs - Pramod
• SharePoint Object Model – Farm, Web Application, Site Collection, Sites and Site elements
• Navigation, Access control and security, Site directory, Site columns, Content types
• Lists and Views, Search, Extra-net Usage

Module 2: Site Tools – 2 Hours – Tahir
• Create custom lists
• Create custom default views for lists
• Create custom web pages and web part zones
• Insert and configure web parts
• Connect web parts to filter data

Module 3: Master Pages – 2 Hours – Tahir
• Understand the structure of master pages.
• Modifying Master Pages
• Creating a Custom Master Page
• Creating a Custom Cascading Style Sheet
• Creating a Web Page from a Master Page
• Understand the purpose and use of Cascading Style Sheets.
• Attach and customize master pages.
• Create content pages from master pages.

Module 4: Forms and Data – 4 Hours – Tahir
• Creating a Formatted View
• Creating a Merged Data Source
• Creating a Custom Data View Page
• Applying Conditional Formatting
• Create and customize Data Views.
• Use conditional formatting to identify data changes.
• Create custom data sources
• Create linked and merged data sources

Module 5: Automating Business Processes - 4 Hours – Tahir
• Implementing Workflows Using Workflow Designer
• Create a SharePoint Designer Workflow
• Using Conditions and Actions
• Verifying and Deploying a Workflow
• Describe Workflows in SharePoint and SharePoint Designer
• Create a workflow through Workflow Designer
• Add conditions and actions to a workflow.

Module 6 and 7: Web Part Development – 4 Hours – Tahir
(Prereq: ASP.NET, C# & SharePoint)
• Creating, deploying and debugging ASP.NET Web Parts in WSS
• Writing CAML to retrieve and store data.
• Deploying WebPart

Module 8: Event Handlers – 4 hrs – Tahir
• List Event Handlers
• Deployment

Model 9: Logical Architecture, Performance Optimization and Tuning – 2 Hours – Pramod
• Client Side Performance issue
• Server side performance issues

Model 10: Best Practices, Information Architecture, Governance Planning - Pramod
• Best Practices for SharePoint implementation and Designing

Official SharePoint Documentation

I have recently contributed to the official SharePoint documentation for developement. Check it out here: https://docs.microsoft.com/en-us...