<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Head.SmackOnTable(); &#187; w00tles</title>
	<atom:link href="http://www.unauthorised-access.com/tag/w00tles/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unauthorised-access.com</link>
	<description>Contains Nuts.</description>
	<lastBuildDate>Fri, 06 Jan 2012 11:15:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Extending Nettiers Part 2 &#8211; Adding an OnItemCommand</title>
		<link>http://www.unauthorised-access.com/2008/11/extending-nettiers-part-2/</link>
		<comments>http://www.unauthorised-access.com/2008/11/extending-nettiers-part-2/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 19:10:20 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[NetTiers]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[w00tles]]></category>
		<category><![CDATA[WebControls]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=57</guid>
		<description><![CDATA[A few days ago, I decided to try to extend the Repeater Control, by adding an OnItemCommand, like the System.Web.UI.WebControl. Simple I thought. Shouldnt be that hard I thought. I couldnt have been more wrong. I have learned alot with the whole experience. I have learned about event bubbling, the way that events get passed [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago, I decided to try to extend the Repeater Control, by adding an OnItemCommand, like the System.Web.UI.WebControl. Simple I thought. Shouldnt be that hard I thought.</p>
<p>I couldnt have been more wrong.</p>
<p>I have learned alot with the whole experience. I have learned about event bubbling, the way that events get passed up the control tree till they are handled by their parents. Iv learned about the way that items that are nested will need to be databound for the event to be fired, even if the data is being shown on the page, you still have to explicitly call DataBind(); And I got some help from a random guy (who works for telerik!) on StackOverflow, thanks!</p>
<p>Basically, this is the way it works. When a user hits a button (Like a &lt;asp:button) on the page, it will bubble up (OnBubbleEvent) on the ITemplate (In this case, the actual type of the ItemRepeater). That will do its magic, work out if its a CommandEventArgs, if it is, then bubble it up:</p>
<pre class="brush: csharp; title: ; notranslate">

protected override bool OnBubbleEvent(object source, EventArgs e)
{
if (e is CommandEventArgs)
{
RepeaterCommandEventArgs args = new RepeaterCommandEventArgs(this, source, (CommandEventArgs) e);
base.RaiseBubbleEvent(this, args);
return true;
}
return false;
}
</pre>
<p>Taken from System.Web.UI.WebControls.RepeaterItem.OnBubbleEvent(object source, EventArgs e);</p>
<p>From there, the Repeater will intercept that, then process it:</p>
<pre class="brush: csharp; title: ; notranslate">
private static readonly object EventItemCommand = new object();

protected override bool OnBubbleEvent(object sender, EventArgs e)
{
bool flag = false;
if (e is RepeaterCommandEventArgs)
{
this.OnItemCommand((RepeaterCommandEventArgs)e);
flag = true;
}
return flag;
}

protected virtual void OnItemCommand(RepeaterCommandEventArgs e)
{
RepeaterCommandEventHandler handler = (RepeaterCommandEventHandler)base.Events[EventItemCommand];
if (handler != null)
{
handler(this, e);
}
}

public event RepeaterCommandEventHandler ItemCommand
{
add
{
base.Events.AddHandler(EventItemCommand, value);
}
remove
{
base.Events.RemoveHandler(EventItemCommand, value);
}
}
</pre>
<p>This is where the fun starts. First off, in the RepeaterItem source code, you cannot call:</p>
<pre class="brush: csharp; title: ; notranslate">
RepeaterCommandEventArgs args = new RepeaterCommandEventArgs(&lt;strong&gt;this&lt;/strong&gt;, source, (CommandEventArgs) e);
base.RaiseBubbleEvent(this, args);
</pre>
<p>because <strong>this</strong> refers to a RepeaterItem, which, in my case, it is not because its a Nettiers generated RepeaterItem. So you have to go off and create your own CommandEventArgs. If you create your own EventArgs, the event handler <strong>RepeaterCommandEventHandler </strong>wont work, because its not of the type <strong>RepeaterCommandEventArgs</strong>. Which is a pain in the arse!</p>
<p>Once you have created the EventArgs and the event handler though, its fairly simple from there &#8211; you just modify the Reflector&#8217;ed code (From the RepeaterControl), to get it to handle your custom Repeater Item&#8217;s event, and not the RepeateItem default event which you cant even call!</p>
<p>But your not done! I found out that the command wont get called when someone clicky&#8217;s on it, because you havnt called DataBind(); on the control, which explains some &#8230; oddities I spotted in the code when I was digging around inside the Repeater &#8211; I kept finding calls to &#8220;EnsureDataBound()&#8221; &#8211; which is called OnPreRender:</p>
<p><img class="alignnone size-full wp-image-58" title="windowclipping-75" src="http://www.unauthorised-access.com/wp-content/uploads/2008/11/windowclipping-75.png" alt="" width="445" height="73" /></p>
<p>Note: I will provide code samples and Nettiers templates very soon, as soon as I have integrated my changes into Nettiers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2008/11/extending-nettiers-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pet Project &#8211; Personal ANPR</title>
		<link>http://www.unauthorised-access.com/2008/09/pet-project-personal-anpr/</link>
		<comments>http://www.unauthorised-access.com/2008/09/pet-project-personal-anpr/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 18:02:57 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[R&D Lab]]></category>
		<category><![CDATA[anpr]]></category>
		<category><![CDATA[pet project]]></category>
		<category><![CDATA[R&D]]></category>
		<category><![CDATA[w00tles]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=45</guid>
		<description><![CDATA[Well iv got a pet project, its creaing my own Automatic Numberplate Recognition System. Why? Because I think it will be very technically challenging to do it in the .net framework. This is what I have sofar, from an image like this: it picks up the following: Not bad, if i say so myself. It [...]]]></description>
			<content:encoded><![CDATA[<p>Well iv got a pet project, its creaing my own Automatic Numberplate Recognition System. Why? Because I think it will be very technically challenging to do it in the .net framework.</p>
<p>This is what I have sofar, from an image like this:</p>
<p><a href="http://www.unauthorised-access.com/wp-content/uploads/2008/09/ph_r0014102.jpg"><img class="alignnone size-medium wp-image-46" title="ANPR 1" src="http://www.unauthorised-access.com/wp-content/uploads/2008/09/ph_r0014102-300x220.jpg" alt=""  width="300" height="220"/></a></p>
<p>it picks up the following:</p>
<p><a href="http://www.unauthorised-access.com/wp-content/uploads/2008/09/defaultaspx.jpg"><img class="alignnone size-medium wp-image-47" title="ANPR Pickup 1" src="http://www.unauthorised-access.com/wp-content/uploads/2008/09/defaultaspx.jpg" alt="" width="89" height="21" /></a></p>
<p>Not bad, if i say so myself. It needs hell of alot of work though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2008/09/pet-project-personal-anpr/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

