<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Vikram Lakhotia : Event Handler</title><link>http://weblogs.asp.net/vikram/archive/tags/Event+Handler/default.aspx</link><description>Tags: Event Handler</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Sharepoint Adding event handler to the list with the help of a generic Console Application</title><link>http://weblogs.asp.net/vikram/archive/2009/01/07/Sharepoint-Adding-event-handler-to-the-list-with-the-help-of-a-generic-event-handler.aspx</link><pubDate>Wed, 07 Jan 2009 07:42:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6823293</guid><dc:creator>vik20000in</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/vikram/rsscomments.aspx?PostID=6823293</wfw:commentRss><comments>http://weblogs.asp.net/vikram/archive/2009/01/07/Sharepoint-Adding-event-handler-to-the-list-with-the-help-of-a-generic-event-handler.aspx#comments</comments><description>&lt;META content=Word.Document name=ProgId&gt;
&lt;META content="Microsoft Word 11" name=Generator&gt;
&lt;META content="Microsoft Word 11" name=Originator&gt;&lt;LINK href="file:///C:%5CDOCUME%7E1%5Cviktiot%5CLocal%20Settings%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel=File-List&gt;
&lt;STYLE&gt;
&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:536871559 0 0 0 415 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;
	text-underline:single;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:1752241005;
	mso-list-template-ids:-1037253570;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:;
	mso-level-tab-stop:.5in;
	mso-level-number-position:left;
	text-indent:-.25in;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--&gt;
&lt;/STYLE&gt;

&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;&lt;?xml:namespace prefix = u1 /&gt;&lt;u1:p&gt;While working with Sharepoint list many a times developers need to create special event handler for the list based on their requirement. Once the event handler assembly is created we have to deploy the Assembly in GAC. And then attach the event handler to the list for which the event handler is created. &lt;u1:p&gt;&lt;/u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;&lt;u1:p&gt;For attaching an event handler with the list we need to create a console application which would be used to attach the event handler to the list. Normally developers create separate console application to attach event handler to the different list. &lt;u1:p&gt;&lt;/u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;&lt;u1:p&gt;What we can easily do create a single console application which would take some parameter form a configuration file and attach the event handler with the specified list. Developers need to provide the required data to attach the event handler in the configuration file. &lt;u1:p&gt;&lt;/u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;&lt;u1:p&gt;The zipped console application is available &lt;A title="Add Event Handler Attachment" href="http://weblogs.asp.net/vikram/attachment/6823293.ashx" target=_blank mce_href="http://weblogs.asp.net/vikram/attachment/6823293.ashx"&gt;here&lt;/A&gt;.&lt;u1:p&gt;&lt;/u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt; 
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;&lt;u1:p&gt;The console application does the work of attaching the event handler to the list. The console application needs 5 different values from the appsettings section of the configuration file.&lt;u1:p&gt;&lt;/u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt; 
&lt;UL type=disc&gt;
&lt;LI class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;&lt;u1:p&gt;SiteCollectionURL&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt; - Takes the URL of the Site where the list resides. Example – “&lt;A href="http://www.example.com/" mce_href="http://www.example.com/"&gt;http://www.example.com&lt;/A&gt;”&lt;u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;RecordListName&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt; – Takes the name of the list on which the event handler should be attached. Example – “ListOfFriend”&lt;u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;EventHandlerName&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt; – Name of the eventhandler that should be applied like ItemUpdating. If there are more than one event handler, then user can pass the venet handler as a comma seperated list ItemDeleting,ItemUpdating &lt;u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;ClassName&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt; – FullName of the class where the code for the event handler has been written. Example – SharePoint.Vikram.EventHandlers.FriendList&lt;u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;AssemblyName&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt; – Name of the assembly where the class for the event handler - SharePoint.Vikram.EventHandlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faeb5f91b6c4621e&lt;u1:p&gt;&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;&lt;u1:p&gt;Vikram&lt;/u1:p&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6823293" width="1" height="1"&gt;</description><enclosure url="http://weblogs.asp.net/vikram/attachment/6823293.ashx" length="2917" type="application/x-zip-compressed" /><category domain="http://weblogs.asp.net/vikram/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/vikram/archive/tags/Sharepoint/default.aspx">Sharepoint</category><category domain="http://weblogs.asp.net/vikram/archive/tags/Event+Handler/default.aspx">Event Handler</category></item></channel></rss>