Post 3
Overview
I will describe three ways to deploy your assembly’s events.
1) Manage EventReceivers via Code
2) Deploy event handlers using the Feature framework of MOSS 2007
3) A cool custom Site Settings Application I built to manage (view, add, edit and delete) event handlers.
Managing EventReceivers via Code
The site (SPWeb) object, the list (SPList) object and the Content Type (SPContentType) object expose a collection called EventReceivers based on the SPEventReceiverDefinitionCollection class.
This collection maintains a set of SPEventReceiverDefinition objects (events) attached to a site, list or content type.
Adding Event Handlers (SPEventReceiverDefinition)
This class provides an “Add” method to attach a new SPEventReceiverDefinition (We created and deployed these to MOSS in Post 1 and 2.) The Add method asks for three bits of information:
· SPEventReceiverType: This tells SharePoint the type of event receiver we are adding to the EventReceiver collection.
· Assembly name: The name of the assembly. E.g.“Litwarehandlers, Version 1.0.0.0, Culture=neutral, PublicKeyToken=a6ab42c509981682”
· Class name: The name of the class. E.g.“Litwarehandlers.SiteHandlerClass”
(An easy way to get this information is to use our trusty old friend, Lutz Roeder’s Reflector application. Simply reflect the class and copy and paste the information you need.)
Once attached, the site, list or content type will now start picking up these events and executing your assemblies code.
Modifying Sequence Numbers
Another important property you may want to set for each event you attach is the Sequence Number. The sequence number determines the order your event assemblies’ fire. This is especially important when you have created multiple assemblies that are all attached to the same Site, List or Content Type event.
To modify the Sequence Number, you need to retrieve the SPEventReceiverDefinition object from the EventReceivers collection.
· Site: site.EventReceivers
· List: list.EventReceivers
· Content Type: site.ContentTypes[content type name].EventReceivers
A suggested best practice (and only my opinion), do not use sequence numbers below 10000 as SharePoint uses event handlers extensively to run SharePoint Workflows, etc. These event handlers use Sequence Numbers, starting at 1000.
Deleting Event Handlers (SPEventReceiverDefinitions)
When removing definitions, here is what you have to do:
Site:
· Attach to the site (SPWeb)
· Lookup the SPEventReceiverDefinition object in the site.EventReceivers collection.
· Use the delete method of the SPEventReceiverDefinition object to remove it from the collection.
· Call the site.Update() method.
List:
· Attach to the site (SPWeb)
· Retrieve the list : (site.Lists[GUID or listname])
· Lookup the SPEventReceiverDefinition object in the list.EventReceivers collection.
· Use the delete method of the SPEventReceiverDefinition object to remove it from the collection.
· Call the list.Update() method.
Content Types:
· Attach to the site (SPWeb)
· Retrieve the SPContentType (site.ContentTypes[SPContentTypeId])
· Retrieve the SPEventReceiverDefinition object : (SPContentType.EventReceivers[GUID])
· Use the delete method of the SPEventReceiverDefinition object to remove it from the collection.
· Call the SPContentType.Update() method.
Managing assemblies using Features
It is possible to create a feature that deploys your event handler to the assembly.
MSDN has an example on how to achieve this:http://msdn2.microsoft.com/en-us/library/ms453149.aspx
See screenshot of the xml you need to write to deploy an event via the features framework:
Limitations:
· It is difficult to see what event handlers are installed and the sequence they are firing for a site, list or content type. To modify, requires rebuilding the feature with the correct settings.
· Using a feature, “hardcodes” the event handler to an individual list or Content Type. Each time you want to use the SAME event handler, you are forced to write another feature to register it.
In my opinion, wrapping functionality as a feature is cool, but is overkill for registering event handlers. This is my reason for building a view, add, edit and remove application via Site Settings. See below! J
Managing EventReceivers using Site Settings application assemblies
Features
The Manage Event Handler site settings application provides you with the ability to view all events that have been associated to a site, any list of that site, and all Content Types for that site.
You can add event handlers, edit the sequence numbers and delete events registrations. Once the feature is activated, it is accessible from the Site Settings of any site
Feature – Event Handler Screenshot
Site Settings Event Handlers Screenshot
View Event Hhandlers Screenshot:
Add Event handlers Screenshot:
Edit Event handlers Screenshot:
Delete Event handlers Screenshot
Firstly, download the solution deployment code and wsp file from CodePlex here, and install in your SharePoint environment. (If you pick up any issues or have feature requests, please let me know so that I can add these to future releases.)
How to install
1. Follow the steps in my previous post in the "Deploying your assembly to staging and production" section. It provides step by step instructions on how to install a wsp file.
2. Navigate to any site and open Site Settings.
3. Open “Site Features” under the Site Administration column.
4. Activate the new feature called “Manage Event Handlers”. This enables event handler management application for this site.
5. Navigate back to Site Settings. A new option is now available under the “Site Administration column” called “Manage Event Handlers”. Select this option.
Notes
I have removed the ability to edit or delete native SharePoint generated event associations as this may affect the stability of SharePoint Out-Of-The-Box functionality. Only YOUR events can be managed.
Content Types (and their associated event handlers) can only be managed via the root site of the site collection.
In case you are wondering how to go about building your own site settings applications I have posted the code on CodePlex. I am planning on building an additional site settings administration application to manage and configure site properties.
Summary
If you have any questions, add a comment and time permitting, I will try to respond as soon as possible
So,choosing their table service volition be home business, and Indite cognitive content based on relevant topics.
ReplyDeletePeople are invariably get wind on the answering automobile is yours.
or else, Focal point on making sure all contentedness is relevant to the topic,
and that article titles, you real need your services?
Here is my weblog: business at home
This is not a pretty simple situation to cope with and a grain body' approach or possibly a attempting to draw overall harmony to our life makes the situation easier to along with. The reason for using an infra-red sauna is for your health benefits.
ReplyDeleteMy web site :: infrared heaters canada comfort zone
You need instead of gather any articles required for loan application and nor do you need to get to send her over fax to be able to the lender.
ReplyDeleteThe type of borrower has at complete that form with his basic details.
Also visit my homepage: pikavippi laki
For new companies, there are various affordable Engines Packages offered from seo services Companies offer affordable SEO Systems and Web
ReplyDeletePromotion Services. But like anything else, SEO can be counterfeited.
Look into my weblog - seo service overview
google law firm
ReplyDeleteHello just wanted to give you a quick heads up. The words in your content seem to be running off the screen in Ie.
ReplyDeleteI'm not sure if this is a formatting issue or something to do with web browser compatibility but I thought I'd post to let you know.
The design look great though! Hope you get the issue fixed soon.
Cheers
Also visit my website ... Full Article
Hi! I just noticed your website: Blogger: Sharepoint 2013/2010/2007
ReplyDeletewhen I was surfing around reddit.com. It looks as though someone loved your website
so much they decided to bookmark it. I'll absolutely be coming here more often.
My homepage; Suggested Browsing
Hi. I was considering adding a backlink back to your
ReplyDeletesite since both of our sites are based around the same topic.
Would you prefer I link to you using your site address:
http://www.blogger.com/comment.g?blogID=3138753744371217570&postID=8554480092661203194 or blog title:
Blogger: Sharepoint 2013/2010/2007. Please let me know at your earliest convenience.
Thank you
Check out my web site ... important site
Hello there. Sorry to hassle you but I happened to run across your blog and noticed
ReplyDeleteyou're using the exact same theme as me. The only problem is on my website, I'm unable to get the style and design
looking like yours. Would you mind e-mailing me at:
celestaburgess@yahoo.de so I can get this figured out.
By the way I've bookmarked your web site: http://www.blogger.com/comment.g?blogID=3138753744371217570&postID=8554480092661203194 and will be visiting frequently. Thank you!
Have a look at my website - cheap car insurance rate
Hey there. I was thinking of adding a link back to your site
ReplyDeletesince both of our web sites are based around the same niche.
Would you prefer I link to you using your site address: http://www.
blogger.com/comment.g?blogID=3138753744371217570&postID=8554480092661203194 or web site title:
Blogger: Sharepoint 2013/2010/2007. Please
make sure to let me know at your earliest convenience.
Cheers
Have a look at my web site external link
I'm really enjoying the design and layout of your blog. It's a very easy
ReplyDeleteon the eyes which makes it much more pleasant for me to come here and visit more often.
Did you hire out a designer to create your theme? Great work!
Visit my web-site - pcfuchs.info
Hi! I've been following your website for some time now and finally got the bravery to go ahead and give you a shout out from Kingwood Tx! Just wanted to tell you keep up the great job!
ReplyDeleteMy weblog http://zachszombiesauce.ning.com/
I've gone ahead and added a link back to your web page from one of my clientele requesting it. I've used your web page
ReplyDeleteURL: http://www.blogger.com/comment.g?blogID=3138753744371217570&postID=8554480092661203194 and blog title: Blogger: Sharepoint 2013/2010/2007 to make sure you
get the correct anchor text. If you woud like to check out where your link has been placed, please
contact me at: margiegroff@gmail.com. Appreciate it
my weblog ... auto insurance rates
Good day I am so glad I found your website, I really found
ReplyDeleteyou by mistake, while I was searching on Aol for something else,
Regardless I am here now and would just like to say thanks a lot for a fantastic post and a all round exciting blog (I also
love the theme/design), I don’t have time to go through it all at
the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to
read a lot more, Please do keep up the awesome
b.
my web blog - check my site []
Hi there. I noticed your website title, "Blogger: Sharepoint 2013/2010/2007" does not really reflect the content of your web site.
ReplyDeleteWhen composing your blog title, do you think
it's best to write it for Search engine optimisation or for your readers? This is something I've been battling with
because I want good search rankings but at the same time I want the best quality for my visitors.
Take a look at my web page - useful reference
Hello there just happened upon your blog from Yahoo after I entered
ReplyDeletein, "Blogger: Sharepoint 2013/2010/2007" or something similar (can't quite remember exactly). Anyways, I'm relieved I found
it because your subject material is exactly what I'm searching for (writing a college paper) and I hope you don't mind if I gather some material from here and I will of course credit you as
the reference. Thanks for your time.
Have a look at my website - just click the up coming post - -
I'm new to developing web sites and I was wanting to know if having your site title relevant to your content really that critical? I see your title, "Blogger: Sharepoint 2013/2010/2007 " does appear to be spot on with what your website is about yet, I prefer to keep my title less content descriptive and based more around site branding. Would you think this is a good idea or bad idea? Any kind of help would be greatly valued.
ReplyDeleteLook at my web blog ... visit their website
Wonderful blog! I found it while searching on Yahoo News.
ReplyDeleteDo you have any tips on how to get listed in
Yahoo News? I've been trying for a while but I never seem to get there! Thanks
Feel free to surf to my blog post seo link building - -
Very good blog you have here but I was curious if you knew of any user discussion forums
ReplyDeletethat cover the same topics talked about in this article?
I'd really like to be a part of group where I can get comments from other knowledgeable people that share the same interest. If you have any suggestions, please let me know. Kudos!
My blog post; get backlinks
Hey just wanted to give you a quick heads up. The words in your content seem to be running
ReplyDeleteoff the screen in Firefox. I'm not sure if this is a formatting issue or something to do with web browser compatibility but I figured I'd post to let you know.
The layout look great though! Hope you get the issue solved soon.
Thanks
My web site ... useful content
My partner and I absolutely love your blog and find the majority of
ReplyDeleteyour post's to be precisely what I'm looking for.
Do you offer guest writers to write content in your case?
I wouldn't mind producing a post or elaborating on most of the subjects you write with regards to here. Again, awesome website!
Also visit my site - source for this article :: ::
Having read this I thought it was rather informative. I
ReplyDeleteappreciate you taking the time and energy to put this content together.
I once again find myself personally spending way
too much time both reading and posting comments.
But so what, it was still worthwhile!
Review my weblog helpful resources ()
I am really enjoying the theme/design of your web site. Do you ever run into any browser compatibility problems?
ReplyDeleteA handful of my blog audience have complained about my website not
operating correctly in Explorer but looks great
in Opera. Do you have any ideas to help fix this
issue?, more at view publisher site!
Hmm it looks like your website ate my first comment (it was super long) so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying your
ReplyDeleteblog. I as well am an aspiring blog writer but I'm still new to the whole thing. Do you have any tips for beginner blog writers? I'd really appreciate it.
Feel free to visit my web blog: just click the following website
Hey there! Someone in my Myspace group shared this website
ReplyDeletewith us so I came to take a look. I'm definitely loving the information. I'm
bookmarking and will be tweeting this to my followers!
Terrific blog and terrific style and design.
my weblog - one way Link building company
I'm new to developing sites and I was wanting to know if having your site title relevant to your articles and other content really that critical? I notice your title, "Blogger: Sharepoint 2013/2010/2007 " does appear to be spot on with what your blog is about however, I prefer to keep my title less content descriptive and based more around site branding. Would you think this is a good idea or bad idea? Any kind of help would be greatly valued.
ReplyDeleteMy web-site :: relevant link building ()
Right now it seems like Movable Type is the top blogging platform
ReplyDeleteavailable right now. (from what I've read) Is that what you're using on your blog?
my weblog seo link building service
Really i enjoyed very much. And this may helpful for lot of peoples. So you are provided such a nice and great article within this.
ReplyDeleteManpower Consultancy in Chennai
Hr Consultancy in Chennai
Recruitment Consultancy in Chennai
Great post! I am see the programming coding and step by step execute the outputs.I am gather this coding more information. It's helpful for me my friend. Also great blog here with all of the valuable information you have.
ReplyDeleteSharepoint Training in Chennai