Monday, September 21, 2009

SharePoint Manger 2007 For Adding Customized content Type

Hello All,

First let me explain, what is content Type? Its FAQ and very important to understand,
A content type is a reusable collection of settings you want to apply to a certain category of content. Content types enable you to manage the metadata and behaviors of a document or item type in a centralized, reusable way.
for the exact definition visit
For Customizing the New\Edit\Display Forms of Custom List
use SharePoint Manager which can be downloaded at codeplex
its a great tool for customizing content Types
Find more links on google for how to do it
like 1) http://sharepointmagazine.net/technical/development/customizing-the-user-experience-of-sharepoint-content-type-user-interface-part-4-of-6
2)Book on Share Point Manager 2007

Saturday, September 12, 2009

validation with standard sharepoint error Page on ListItem adding event

To add validation to listitem adding event( to restrict the no of items to be added per day)in list
1) Visual studio 2008 -->Sharepoint-->Empty Project
2)In solution explorer-->add new item --> content type
3)And check content type with event receiver, you will find three 2 .cs files and 1 xml file

in this file uncomment the ItemAdding event

add the following code required for the restriction

public override void ItemAdding(SPItemEventProperties properties)

int perday = GetItemCountPerDay();
string dt= properties.AfterProperties[CONST_FIELD_DATETIME].ToString();
SPQuery query = QueryItemForPerDay(dt);

using (SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))

SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].GetItems(query);

if ((collItems != null) && (collItems.Count > perday - 1))
properties.ErrorMessage = String.Format("Adding items to this list is not supported because per day only allowed add {0} items.", PER_DAY);
properties.Cancel = true;


c).xml file

4)Deploy the project
To enable the content type
go to the site Site actions -->create new custom list --> enable the content types for the site
list settings-->advanced settings--selct deployed content type

5)Go to wss --> virtual diectories-> site --> open the web.config file and do the following changes


safemode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false"

customerrors mode="On"