<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Accessing Properties/Methods of a Page through an embedded UserControl</title>
	<atom:link href="http://quickduck.com/blog/2006/12/06/accessing-propertiesmethods-of-a-page-through-an-embedded-usercontrol/feed/" rel="self" type="application/rss+xml" />
	<link>http://quickduck.com/blog/2006/12/06/accessing-propertiesmethods-of-a-page-through-an-embedded-usercontrol/</link>
	<description>Straight from the mind of geniuseseses....</description>
	<lastBuildDate>Thu, 29 Jul 2010 06:56:25 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: ben</title>
		<link>http://quickduck.com/blog/2006/12/06/accessing-propertiesmethods-of-a-page-through-an-embedded-usercontrol/comment-page-1/#comment-9</link>
		<dc:creator>ben</dc:creator>
		<pubDate>Thu, 07 Dec 2006 09:22:19 +0000</pubDate>
		<guid isPermaLink="false">http://quickduck.com/blog/?p=11#comment-9</guid>
		<description>All good points my friend.

I originally wrote the article using a delegate instead of the EventHandler and didn&#039;t think to go the whole hog when changing over.

Thanks for the pickup.</description>
		<content:encoded><![CDATA[<p>All good points my friend.</p>
<p>I originally wrote the article using a delegate instead of the EventHandler and didn&#8217;t think to go the whole hog when changing over.</p>
<p>Thanks for the pickup.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerrod</title>
		<link>http://quickduck.com/blog/2006/12/06/accessing-propertiesmethods-of-a-page-through-an-embedded-usercontrol/comment-page-1/#comment-8</link>
		<dc:creator>Gerrod</dc:creator>
		<pubDate>Thu, 07 Dec 2006 09:19:43 +0000</pubDate>
		<guid isPermaLink="false">http://quickduck.com/blog/?p=11#comment-8</guid>
		<description>You should actually be declaring your EventHandler property in the user control like this -

public event EventHandler AutomobileChangeHandler;

This also saves you from having to explicitly create a property for the AutomobileChangeHandler.

The reason that you&#039;re supposed to do it like this is because the &quot;event&quot; keyword hides the complexity of event registration and de-registration. But, you can explicitly implement your own storage mechanism for event handlers, similar to how you create a property - except instead of &quot;get&quot; and &quot;set&quot;, you use &quot;add&quot; and &quot;remove&quot; - 

&lt;pre&gt;&lt;code&gt;
private IList&lt;EventHandler&gt; handlers = new List&lt;EventHandler&gt;();
public event EventHandler AutomobileChangeHandler {
    add {  handlers.Add(value); }
    remove { handlers.Remove(value); }
}
&lt;/code&gt;&lt;/pre&gt;

Obviously, using the += and -= notation is the shorthand way of calling the add and remove properties of an event.</description>
		<content:encoded><![CDATA[<p>You should actually be declaring your EventHandler property in the user control like this -</p>
<p>public event EventHandler AutomobileChangeHandler;</p>
<p>This also saves you from having to explicitly create a property for the AutomobileChangeHandler.</p>
<p>The reason that you&#8217;re supposed to do it like this is because the &#8220;event&#8221; keyword hides the complexity of event registration and de-registration. But, you can explicitly implement your own storage mechanism for event handlers, similar to how you create a property &#8211; except instead of &#8220;get&#8221; and &#8220;set&#8221;, you use &#8220;add&#8221; and &#8220;remove&#8221; &#8211; </p>
<pre><code>
private IList<eventhandler> handlers = new List</eventhandler><eventhandler>();
public event EventHandler AutomobileChangeHandler {
    add {  handlers.Add(value); }
    remove { handlers.Remove(value); }
}
</eventhandler></code></pre>
<p>Obviously, using the += and -= notation is the shorthand way of calling the add and remove properties of an event.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
