Figure 5-8: Add Feature Context menu item in .NET

Encode QR Code ISO/IEC18004 in .NET Figure 5-8: Add Feature Context menu item
Figure 5-8: Add Feature Context menu item
Drawing QR In Visual Studio .NET
Using Barcode drawer for .NET framework Control to generate, create QR Code JIS X 0510 image in .NET applications.
6 Right click Feature1 and select Add Event Receiver from the context menu
Quick Response Code Scanner In VS .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
Creating Feature Event Receiver Projects
Bar Code Encoder In .NET Framework
Using Barcode creator for VS .NET Control to generate, create barcode image in .NET applications.
The code file for Feature1EventReceivercs shown in Listing 5-8 is added to the project
Bar Code Reader In .NET Framework
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications.
Listing 5-8: Feature1EventReceivercs
Quick Response Code Printer In Visual C#.NET
Using Barcode printer for Visual Studio .NET Control to generate, create QR Code image in .NET framework applications.
             
Denso QR Bar Code Maker In .NET Framework
Using Barcode creation for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
   
Generating Denso QR Bar Code In Visual Basic .NET
Using Barcode encoder for .NET framework Control to generate, create Denso QR Bar Code image in VS .NET applications.
 
Encode ANSI/AIM Code 39 In .NET
Using Barcode generation for .NET Control to generate, create Code 39 Extended image in VS .NET applications.

Bar Code Maker In Visual Studio .NET
Using Barcode creation for VS .NET Control to generate, create bar code image in Visual Studio .NET applications.
  
Painting Bar Code In .NET
Using Barcode creation for .NET framework Control to generate, create barcode image in .NET framework applications.
   
EAN-13 Supplement 5 Drawer In .NET Framework
Using Barcode generation for VS .NET Control to generate, create European Article Number 13 image in VS .NET applications.
   
Uniform Symbology Specification Codabar Encoder In Visual Studio .NET
Using Barcode encoder for Visual Studio .NET Control to generate, create 2 of 7 Code image in .NET framework applications.
   
Code 39 Full ASCII Creation In .NET
Using Barcode maker for ASP.NET Control to generate, create USS Code 39 image in ASP.NET applications.
5: SharePoint Event Receivers
UCC-128 Creation In Java
Using Barcode maker for Java Control to generate, create EAN / UCC - 14 image in Java applications.
    
Code 128 Generation In VB.NET
Using Barcode generation for Visual Studio .NET Control to generate, create Code 128C image in VS .NET applications.
      
ECC200 Creation In Java
Using Barcode generation for Java Control to generate, create Data Matrix image in Java applications.
The feature event receiver class is structured similarly to the other event receivers discussed earlier But you will notice that all methods are already in the class and they are commented out Instead of choosing events in the wizard or toggling the setting in the Properties window, for feature events we only need to uncomment the code for the events we want to handle What about the Elementsxml file Where is the information about the event receiver stored For feature event receivers this information is stored in the Featurexml file instead This file contains all necessary information needed for the feature event receiver to be deployed and correctly registered, including the event receiver assembly and class If we wanted to change these values in the Featurexml file we can do so using the feature designer by double-clicking the Feature1feature file The event receiver assembly and event receiver class values are displayed in the Properties window As before, a token is used to specify the assembly in class Table 5-9 shows the replaceable parameters and sample values to which these parameters resolve when a project is deployed
Code128 Encoder In Java
Using Barcode drawer for Java Control to generate, create Code 128 Code Set B image in Java applications.
Creating Feature Event Receiver Projects
ANSI/AIM Code 39 Encoder In VB.NET
Using Barcode printer for .NET Control to generate, create Code39 image in .NET framework applications.
TABLE 5-9: A Feature s Receiver Assembly and Receiver Class Properties
Bar Code Drawer In Java
Using Barcode generation for Java Control to generate, create bar code image in Java applications.
Property Name Receiver Assembly
Paint Barcode In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create barcode image in ASP.NET applications.
Property Value $SharePointProject AssemblyFullName$
Resolved Value MyLists, Version=1000, Culture=neutral, PublicKeyToken= 6b8440479dc58448 MyListsFeaturesFeature1 Feature1EventReceiver
Receiver Class
$SharePointType453d7f23a25a-4bea-a02f-9b094482c727 FullName$
The receiver assembly property resolves to the fully qualified name of the assembly that contains the assembly name, version, culture, and a public key The receiver class resolves to the full class name One interesting part of the receiver class property value is the GUID, which is used in the token to distinguish between different event receiver classes this GUID is used to disambiguate between multiple features in a project The same GUID in the receiver class property value is an attribute of the event receiver class in the code file as shown in Listing 5-9
Listing 5-9: GUID Attribute on the Event Receiver Class
  
About Changing the GUID
Generally you shouldn t have to change the GUID in either the class file or Featurexml file, but if you do, make sure the GUID in the code file matches the one in the Featurexml file
Now we are ready to write code that is triggered when our feature is activated that will create lists We will also write code to delete the same
5: SharePoint Event Receivers
lists when the feature is deactivated Open the code file (Feature1EventReceivercs) and uncomment the FeatureActivated and FeatureDeactivating methods Before we add code to the event handler we need to define our list names Add the code in Listing 5-10 to the event receiver class
What s the Difference Between Installing and Activating
A SharePoint feature can be activated for its scope only after it is successfully installed on the SharePoint server And, if a feature is installed it can t be used on the SharePoint until it s activated Think about it this way: You must turn the key to activate the engine in your car before you can drive the car Having a car installed in your garage doesn t mean you can drive it you have to activate it first
Listing 5-10: Defining the List Names in Event Receiver Class
       
Now that we defined the list names we can write the code that adds the lists to SharePoint when the feature is activated Uncomment the FeatureActivated method then add the code in Listing 5-11 to the method
Listing 5-11: Code for Adding the Lists to the SharePoint
        
                   
Deploying and Debugging Event Receiver Projects
To add the lists to SharePoint we need to set a reference to the SharePoint site where the lists should be created For more information on using the SharePoint object model see 3, Introduction to the SharePoint Object Model and for more information on working with lists see 4, SharePoint Lists We are using the Parent property of the feature to get to the SPWeb object for the SharePoint site Once we have an SPWeb object we call the Add method on Lists to add the lists Creating a list is simple: we just need to pass the list title, the description, and the list template type to the Add method Note that the Add method has multiple overrides and we could pass different parameters, such as custom XML schema, list instance feature definition, and quick launch options Deleting lists is just as easy as adding them Uncomment the FeatureDeactivating method and add the code from Listing 5-12 to the method