About Me

Calgary, Alberta, Canada
Some know me as Phani, many know me as 'PK'… Mr.Perfect

Thursday, December 2, 2010

Lab 2 - SharePoint Foundation Development

Lab Time: 30 Minutes
Lab Overview: In this lab you will begin to write and test c# code using the SharePoint Foundation 2010 object model.

Exercise 1: SharePoint 2010 Object Model Programming

Pre-Requisites: SharePoint 2010, Visual Studio.

Solution Framework 
  • Launch Visual Studio from windows start menu. Start > All Programs > Microsoft Visual Studio 2010 >Microsoft Visual Studio 2010.
  • Create a new console application based on .NET Framework 3.5
  • Once the new project has been created check the follwoing
    • Target Framework

    • Platform Target
  • Add a reference to the assembly Microsoft.SharePoint.dll
  • Add a reference to the assembly System.Web.
Activating Developer Dashboard 
  • Modify Program.cs to look like this.
  • Make sure to structure your code inside a using construct so that your code makes an implicit call to the Dispose() method to prevent memory leakage.

  • Run the program (CTRL + F5)
  • Open the site in Internet Explorer. You should see the SharePoint 2010 Developer Dashboard at the bottom of the page.
Note: You can use the site created in Lab 1.


Note: If your content variable turns out to be null, you have to check your project properties. Good chance you haven't selected the x64 platform.

De-Activating Developer Dashboard 

  • Modify the program.cs look like this

  • Run the program (CTRL + F5)
  • Open the site in Internet Explorer. You should see the SharePoint 2010 Developer Dashboard is gone now. 
Creating Lists Programatically - Announcements

  • Modify the program.cs look like this.
  • Run the Program (CTRL + F5)
  • Click on Lists or view all site content on the left hand side navigation.
  • You should see the Announcements list.




In the next post, I will write about introduction to development tools in Visual Studio 2010. 

No comments:

Post a Comment