Sharepoint Dev 1

Friday, November 15, 2013

Run this powershell script to create a site collection at the url

View the new top level site in the browser

Open a site in sharepoint designer

In central administration possible to enable/disable sharepoint designer on an application level basis

At level of site collection also possible to enable/disable sharepoint designer

SharePoint Terminology

  • Farm (SPFarm)
    • Web Application (SPWebApplication)
      • Site Collection (SPSite)
        • Site (SPWeb)
          • List (SPList)
            • Item (SPListItem)
          • Document Library (SPDocumentLibrary)
            • File (SPFile)
            • Folder (SPFolder)

Iterate through all lists of top level site of site collection and output title to console

All the lists in the site, output in the console window

Only show the lists that are not hidden

Turn on developer dashboard

Refresh page, view the developer dashboard

Set the dashboard level to on demand and run the application

Next to welcome menu, little green icon appears allowing to toggle dashboard on and off

Sharepoint solutions

  • Sharepoint development based on solutions
    • Solution is a cab file with a .wsp extension
    • Solution is a container of files distributed as a unit
    • Solution contains manifest with instructions for installer
  • Solutions can be deployed two different ways
    • As a farm solution
    • As a sandboxed solution

What is a sharepoint feature?

    • Unit of design and implementation
    • Building block for creating sharepoint solutions
  • Features can contain elements
    • Menu items, links, list types and list instances
    • Many other element types possible
  • Features can contain event handlers
    • Implemented using a feature receiver class
    • Event handler code can program using SharePoint Object Model

Feature.xml serves as a feature manifest file

  • Defines attributes for feature definition
  • Can reference one or more element manifests
  • Can reference a receiver feature

Element manifest contains declarative elements

  • ListInstance elements creates lists during activation
  • Many other element types available
  • Element manifest can contain many elements
  • feature.xml can reference many element manifests

What is a solution package?

  • A mechanism for best practice deployment
  • Atomic unit of reuse, deployment and versioning
  • A set of files and manifest with installation instructions
  • A cab file with a *.wsp extension

What can be deployed via a solution package?

  • Feature definitions
  • Images
  • Assemblies
  • And much more...

Manifest.xml file

  • Each solution package requires manifest.xml file
    • Mainly serves as instructions to installer on WFE

In server explorer connect and explore contents of sharepoint site

Open extension manager and download the CKS, community kit for sharepoint

Create a new empty sharepoint 2010 project, targeting .net framework 3.5

Specify the url of the sharepoint site to debug against, and select the radio button farm solution, click finish

Add a new web part item to the project

Adds new web part and feature

The webpart.cs file with a line of code

Webpart definition contains string $SharePoint.Project.AssemblyFullName$, token that will be replaced when compiled,the strong name of assembly will be automatically inserted

Element manifest file used to deploy web part definition,modify the property value

Open the feature to see the elements contained in the feature

Open manifest tab to view the feature xml file that is automatically generated

Click on options, possible to add on elements to the xml file

Feature selected,on property window possible to change alot of settings

Set a breakpoint in the webpart and press f5

Site actions, site settings,site collection features, see that the feature has been activated

Edit page, insert, web part, click add

Breakpoint gets hit, press f5 to continue

Save changes, web part has been added to the page

When stop debugging, the feature is retracted and the web part is no longer visible on the page

In solution explorer, select feature1, right click and select add event receiver

Override the methods required for implementation

Default Success Warning Important Info Inverse
B S W I ? O