c# create barcode free CREATING YOUR FIRST CONTENT FACTORY in Font

Creator ECC200 in Font CREATING YOUR FIRST CONTENT FACTORY

CHAPTER 12 CREATING YOUR FIRST CONTENT FACTORY
Make Data Matrix 2d Barcode In None
Using Barcode generation for Font Control to generate, create ECC200 image in Font applications.
www.OnBarcode.com
Make Barcode In None
Using Barcode creator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
More Advanced Concepts
Draw EAN13 In None
Using Barcode encoder for Font Control to generate, create GS1 - 13 image in Font applications.
www.OnBarcode.com
EAN 128 Drawer In None
Using Barcode generator for Font Control to generate, create EAN 128 image in Font applications.
www.OnBarcode.com
You may wonder why I asked you to create a feature with a receiver earlier, rather than just a blank feature. Rest assured that your time of wondering is now over; you are about to be enlightened. What we are going to do here is explore some advanced concepts in order to learn more about the coolness of content types.
Drawing Denso QR Bar Code In None
Using Barcode printer for Font Control to generate, create QR-Code image in Font applications.
www.OnBarcode.com
Encode Code 128B In None
Using Barcode drawer for Font Control to generate, create Code 128B image in Font applications.
www.OnBarcode.com
Preventing News Deletion and Category Change
Drawing Code-39 In None
Using Barcode encoder for Font Control to generate, create Code 3/9 image in Font applications.
www.OnBarcode.com
Encode GS1 - 8 In None
Using Barcode creator for Font Control to generate, create EAN-8 image in Font applications.
www.OnBarcode.com
The editor of Empire Times has decided that news should not be deleted. In addition, news articles should not change categories. I mean, if you have a weather report, chances are it will not be a sports update any time soon. To accomplish this, we are going to utilize an item event receiver. Event receivers are important tools for making sure that the user experience feels right and is secure. In short, an event receiver is a piece of code that fires whenever a certain event happens in SharePoint.
Encode Data Matrix 2d Barcode In VB.NET
Using Barcode creation for .NET Control to generate, create Data Matrix image in .NET applications.
www.OnBarcode.com
Encoding Data Matrix ECC200 In None
Using Barcode printer for Microsoft Word Control to generate, create DataMatrix image in Word applications.
www.OnBarcode.com
Note A thorough investigation of event receivers is a bit outside the scope of this book. Luckily for you, I have a Business Process Management series on my blog that explains event receivers and workflows. Check it out at http://www.understandingsharepoint.com/url/10001.
Encoding Barcode In None
Using Barcode creator for Microsoft Excel Control to generate, create Barcode image in Microsoft Excel applications.
www.OnBarcode.com
PDF-417 2d Barcode Recognizer In C#
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Exercise 12-7. Creating Event Receivers in Content Types
Data Matrix ECC200 Scanner In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Create Code 128B In Java
Using Barcode encoder for Java Control to generate, create Code 128A image in Java applications.
www.OnBarcode.com
In this exercise, you will create two event receivers and attach them to the content types you have created. 1. Add a new class file, for example, in the FeatureCode folder of your solution. Name it something cool, such as TimesNewsEventReceivers.cs. Open the file. Note that if you add the class file to the FeatureCode folder, Visual Studio will add FeatureCode to your namespace. You do not want that. 2. Add a using Microsoft.Sharepoint; statement to the file. 3. Have your class inherit from the SPItemEventReceiver class. Oh, and make the class public. It sort of works best that way. At this point, your file should look something like this: using using using using System; System.Collections.Generic; System.Text; Microsoft.SharePoint;
Generating Code-128 In None
Using Barcode encoder for Software Control to generate, create Code 128 Code Set A image in Software applications.
www.OnBarcode.com
Barcode Generation In Java
Using Barcode generator for BIRT Control to generate, create Barcode image in BIRT applications.
www.OnBarcode.com
namespace EmpireTimes { public class TimesNewsEventReceivers : SPItemEventReceiver { } }
ANSI/AIM Code 39 Generator In Java
Using Barcode maker for Android Control to generate, create Code 3/9 image in Android applications.
www.OnBarcode.com
Generating UCC-128 In Java
Using Barcode creation for Java Control to generate, create UCC-128 image in Java applications.
www.OnBarcode.com
CHAPTER 12 CREATING YOUR FIRST CONTENT FACTORY
UCC-128 Scanner In Visual C#
Using Barcode decoder for .NET framework Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
PDF 417 Creation In Java
Using Barcode creator for Eclipse BIRT Control to generate, create PDF417 image in Eclipse BIRT applications.
www.OnBarcode.com
4. Override the ItemUpdating method. Add the following code to your overridden method: public override void ItemUpdating(SPItemEventProperties properties) { SPListItem item = properties.ListItem; SPFieldLookupValue newValue = new SPFieldLookupValue(item["ArticleCategory"].ToString()); if (newValue.LookupId.ToString() != properties.AfterProperties["ArticleCategory"].ToString()) { properties.ErrorMessage = "You cannot change category"; properties.Cancel = true; } } This method handles the changing of article category. Now we want to avoid deletion of news. 5. Override the ItemDeleting method. Add the following code to your overridden method: public override void ItemDeleting(SPItemEventProperties properties) { properties.Cancel = true; properties.ErrorMessage = "Cannot delete news. If it happened, it happened."; } That takes care of deleting news. Feel free to argue that the editor is an idiot for refusing to delete items, but, hey, I didn t make the rules. Next we need to attach the event receiver to the content type. To do so, as you may remember, we need to add an XML document to the content type. 6. Update the NewsArticle root content type, and add an XML document to the XmlDocuments element as such: <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events"> <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events"> <Receiver> <Name>Updating news article</Name> <Type>ItemUpdating</Type> <SequenceNumber>1</SequenceNumber> <Assembly>EmpireTimes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=[YOUR PUBLIC KEY TOKEN]</Assembly> <Class>EmpireTimes.TimesNewsEventReceivers</Class> <Data /> <Filter /> </Receiver> <Receiver> <Name>Deleting news article</Name>
CHAPTER 12 CREATING YOUR FIRST CONTENT FACTORY
<Type>ItemDeleting</Type> <SequenceNumber>1</SequenceNumber> <Assembly>EmpireTimes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=[YOUR PUBLIC KEY TOKEN]</Assembly> <Class>EmpireTimes.TimesNewsEventReceivers</Class> <Data /> <Filter /> </Receiver> </spe:Receivers> </XmlDocument> Note that [YOUR PUBLIC KEY TOKEN] must be replaced with the public key token for your solution. If you re using WSPBuilder, the easiest way to get this value is to check the Feature.xml file of your feature because this will contain the public key token. 7. Build and then deploy or upgrade your solution. Deactivate and reactivate the feature. Note that if you added the content type to a list in the optional exercise earlier, you must remove and re-add the content type to the list for the changes to take effect.
What we just did was bind a feature receiver to a content type using an XML document. The cool thing about this is that no matter where you now add the content type, the feature receiver will follow. We can still do more. Content types can be tied to other functionality as well. For example, you might want to connect special user actions only to documents or items of a particular type. One method of doing so is with a custom action, which we discussed briefly in 5. Custom actions are the method by which links and items are added to menus and lists in SharePoint. We will explore this further in 13 as well, but I wanted to show you how to connect a custom action to a specific content type.
Copyright © OnBarcode.com . All rights reserved.