Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Feature Receivers

Another kind of event receiver you may find helpful is a feature receiver, which runs your code when a SharePoint feature is activated, deactivated, installed, or updated (with the same ing variations available as well). This allows you to do any kind of setup or cleanup that can’t be handled in the declarative feature.xml and other files associated with your project.

To show this, add a simple feature receiver to the FAQ solution to add an initial question to the list when it is provisioned. To create the feature receiver, go to Solution Explorer in Visual Studio, and under the Features folder, find the web level feature that contains the FAQ list instance (probably Feature2 if you did the project in the same order as the chapter). Right-click the feature and click Add Event Receiver as shown in Figure 2.22. Visual Studio creates a class derived from SPFeatureReceiver, which you can edit to add your event code.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint