Creating & Adding Eventhandler to Sharepoint Doc Library

Adding Events & Registering Events:

http://farhanfaiz.wordpress.com/2007/12/31/creating-adding-an-event-handler/

Get Available Events for Sharepoint Library:

static void GetEvent()
        {
            using (SPSite site = new SPSite("http://moss2003/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPDocumentLibrary doc = (SPDocumentLibrary)web.GetList("Shared Documents");
                  
                    foreach (SPEventReceiverDefinition def in doc.EventReceivers)
                    {
                        Console.WriteLine("Name:{0}",def.Name);
                    }
                }
            }
        }

Work Around for Updating Event Fires Twice:

http://support.microsoft.com/kb/939307/en-us

if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
            {
                //This is when the update event is triggered by check-in.
            }
            else
            {
                //This is triggered by events other than check-in action.
            }


Create Multiple Contents for Document Library:

If you want to get Multiple Templates under Document Library "New" create custom content types for Share point document library. The following URL explains how to create Custom Content with Template.

http://grumpywookie.wordpress.com/2008/08/26/microsoft-word-template-dotx-sharepoint-contenttype/

Create Custom Content Document Templates:

http://platinumdogs.wordpress.com/2010/01/15/provision-a-content-type-with-a-document-template-using-a-feature-part-1/

http://platinumdogs.wordpress.com/2010/01/15/provision-a-content-type-with-a-document-template-using-a-feature-%e2%80%93-part-2/

Comments

Popular posts from this blog

Windows Azure Package Build Error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Resource ID : 1. The request limit for the database is 180 and has been reached.

How to get Client's Location using IPAddress