Friday, December 5, 2008
Code to remove Web part from a page in SharePoint
Friday, September 19, 2008
Code snippet to get all installed languages from sharepoint server Farm
I had a requirement to display all installed languages of a SharePoint server farm in a DropDownList.
Regional Settings of SPWeb has a property named "SPWeb.RegionalSettings.InstalledLanguages", which returns language collection of type
"SPLanguageCollection". The following are the properties of "SPLanguage" instance.

Use the "Display Name" property to get the language display name ex. English and "LCID" property to get the locale ID ex. 1033(for English).
See the below code snippet, which will be used to get the installed languages from a SharePoint server farm.

Hope this will be helpful
Thursday, July 17, 2008
Programmatically uploading site templates to site template gallery

This code uses a configuration file, which has a custom section called “SiteTemplatesSection”. This custom section holds the physical path of each site template.
Friday, July 4, 2008
Programmatically Creating Site Collection in SharePoint
1) Using SharePoint Object Model
2) Using Central Admin’s Admin Web Service
Creation Site Collection using SharePoint Object Model
See the following code snippet, which uses SharePoint Object Model to create site collection.

The Admin Web Service of Central Admin has the following web methods
Thursday, May 29, 2008
Programmatically adding data to SharePoint List’s Choice column
- Dropdown List
- Radio Buttons
- Check Boxes (To Select Multiple Items)
Consider I’ve a list “Resource List” with following columns
Column Name ------ Type
Resource Name --> Single Line of Text
Languages Known --> Choice (C#, VB.NET, Java, C, C++) – Multiselect
“Languages Known” is the CHOICE field (Check Boxes), to select multiple languages known by the resource.When adding new items to the Resouce List, notice that multiple items selected for the ‘Languages Known’ CHOICE column will be seperated by semi colan(‘;’).
I had a requirement to add the list item by code. I have used “ChoiceA;ChoiceB;..ChoiceN” for storing the ListItem’s multi-select CHOICE field. After adding ListItem by code, I have Edited the newly added item in the browser, but no check box has been selected for the item which was added by code.
Then after a little effort I found that the multi-select CHOICE data is stored as “;#ChoiceA;#ChoiceB;#...;#”
See the below code for adding listitem to Resource List.
Below screen shows the newly added Item in the edit mode
Friday, April 4, 2008
Page Hit Counter in SharePoint
Open your site or your sites Master page to insert this component. For the demonstration purpose, I’ve use my default.aspx to insert the “Hit Counter” component. Once the page is opened in SharePoint Designer, place the cursor where you want to insert the hit counter. Go to Insert --> Web Component.

Click on the Web Component, this will display the available web components. You can find different types of other components readily available.

Click on the Hit Counter component, this will display different counter styles. Select any one style from the list. I have selected the below marked style.

Click on “Finish”, this will open the below Hit Counter Properties window.

You can even create your own Hit Counter. Use “Reset counter to” to reset the counter from a given number. To display fixed number of digits use “Fixed number of digits” property. Click on “Ok”, the hit counter will be inserted to your page. The below code will be inserted in your page to display the counter.

Now, preview your page from SharePoint Designer / a Web browser. You can see the Hit Counter incremented for each hit.

You can see the Hit Counter increments for each hit.
