Month: April 2007

SharePoint MasterPages for Site Pages

By default any pages not found in the _Layouts directory have their MasterPage set to the token of ~masterUrl/default.master. This refers them to a property of the SPWeb object stored in SharePoint called MasterUrl which holds the path to the masterpage that will be used.  In a normal site this property is set to _catalogs/masterpage/default.master, which points to the default.master file in the masterpage gallery of the site. Until the page in the gallery is customized it points to the default.master in the Template/Global directory of the 12 hive.  You can use SPD to select a different .master file to be associated with each layout page, but that is page specific.  Never actually edit the default.master page in any sharepoint installation, always create a new masterpage and customize that one, then have your site refer to the new masterpage file for either it’s default or custom masterpage property. You can also use SPD to edit the .master in the Site’s master page gallery, which would apply to every page in the site. You can also use the SharePoint Object model to write a program that will modify the MasterUrl property of the SPWeb object which will change the masterpage for the whole site without unghosting objects to the database like SPD will. Finally, you could edit the masterpagefile attribute of every page using SPD to change what masterpage it...

Read More

SharePoint 2007–Event Handlers

SharePoint isn’t just an application.  It is an extensible application platform.  Easily extended with features that allow you to add custom event handlers to sites, lists, items and content types in your portal. A custom event handler is a .Net assembly that contains the additional business logic you need to run when the event occurs in SharePoint. Examples of custom event handlers can include things like: Retrieve information from a database such as filling in the remaining fields of a list based on a CustomerID (assuming you don’t have an enterprise license for BDC) Call a web service Start a workflow Perform list data validation Convert document to PDF and store in alternative library. Event Types Microsoft.SharePoint.SPWebEventReceiver : "Site Level"   SiteDeleted Occurs after a site collection has been deleted. SiteDeleting Occurs when a site collection is being deleted. WebDeleted Asynchronous Afterevent that occurs after an existing Web site is completely deleted. WebDeleting Synchronous before event that occurs before an existing Web site is completely deleted. WebMoved Asynchronous after event that occurs after an existing Web site has been moved. WebMoving Synchronous before event that occurs before an existing Web site has been renamed or moved to a different parent object.   Microsoft.SharePoint.SPListEventReceiver : "List Level"   FieldAdded Occurs after a field link is added. FieldAdding Occurs when a field link is being added to a content type. FieldDeleted...

Read More