Sharepoint 2010 Development 1

Thursday, December 12, 2013

Create a new empty sharepoint 2010 project

Provide the url and set farm deployment

Add a web part

In the web part display the title and the number of lists

Set the title and description in .webpart xml file

Right click the project and deploy out to the environment

Refresh the page

Click page tab

Click edit page on ribbon

Click insert

Click Web Part

Select category custom

Click add

Click save and close

The webpart on the page displaying the title and count of splist objects

File new console application project

Add a reference to Microsoft.Sharepoint

Reference the current farm object

Iterate through all services in the farm

Display the name of the spwebservices that host web applications

Iterate through all web applications in current web service and display the name and number of sites contained

Iterate through all site collections and display the url and number of sites contained

Iterate through all webs in a site collection and display the title and number of lists contained

Iterate through all lists in the web and display the title

Display all lists in all webs in all site collections in all web applications in all web services in the current farm

Run the program

Output in the console

Create a new class library project

Add this code and references

Build the project in release mode

Open the bin release folder in windows explorer

One option drop the assembly in the GAC, the assembly must be strongly named for that to work

Another option copy the assembly to the virtual directory of the web application of the sharepoint site

Move up one level, find the web.config, open it in visual studio

In the safe controls section, add this line of code

Navigate to sharepoint site, click site actions, site settings, in galleries section click on web parts

Goto documents tab on ribbon, click on new document

Click the check box for the old school web part

Scroll up and click populate gallery

Sharepoint generates the .webpart file

Navigate to home page of site, from site actions menu, edit page, click on insert tab on ribbon then web part

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