Creating List programatically

If yo don’t see the Save Site as Template link, disable the Sharepoitn Publishing Feature and you will see it.

If you get an error on Sharepoint and you need to update the web.config file to display the error, the web.config file is here:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\web.config

Change <customErrors mode=”On” /> to <customErrors mode=”Off” />
Server object model can work on lists across multiple site collection; while client object model can only work on the site collection where the calling app is hosted.

Because Sharepoint Client Object Model references System.Web, so you can’t use .NET 3.5 Framework Client Profile. (WPF, WCF, Windows Forms and Console App)

You typically create an application page when you want to create some very custom UI that displays within SharePoint
but doesn’t need to be customized by each individual user
because application pages don’t support per-user customization. If you need per user customizations, you should create a web part.

Application Page (Add New Item
Sandbox Solution) are not available with Sandbox Solution. VS 2010 doesn’t support WYSIWYG in Application page.

Since VS 2010 doesn‘t support visually editing Sharepiint Application page, you need to drag the controls from Toolbox to the source code view (PLACEHOLDERMAIN) manually. To create an event handler, type a space or letter (see below) and let the Intellisense prompts you to complete the attributes.

CREATE A LIST using server Model

In Sharepoint Application Page, you must using Microsoft.SharePoint.Administration, because Microsoft.Sharepoint.Administration include the implementation of Server Object Model.

Create a farminstance (local farm)
Make a reference to the web service of the local farm
Via the service object, get a list of web applications on this farm

For each web application, get each site collection and add to the combo box.


Create a reference to the site collection (parameter)
For each site under this site collection, get the name and URL and do something.
dispose of the web

Create a new list….

make a reference to the site collection,

Make a reference to the web,

Declare a new empty list (the foreach loop is just to make sure no list of the same name exists)
use web.Lists.Add(…) to add a new list, and then get a LostID
update the list.

CREATE A LIST using Client Model

The ClientContext object serves as the main entry point for accessing the client object model. In addition it is used to access site collections or sites and their dependent client objects.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: