<?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; WebControls</title>
	<atom:link href="http://www.unauthorised-access.com/tag/webcontrols/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>Nesting Repeaters without OnItemDataBound</title>
		<link>http://www.unauthorised-access.com/2009/02/nesting-repeaters-without-onitemdatabound/</link>
		<comments>http://www.unauthorised-access.com/2009/02/nesting-repeaters-without-onitemdatabound/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 19:12:53 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[OnItemDataBound]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[WebControls]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=110</guid>
		<description><![CDATA[And the page result is: abc 12345 def 67890]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-112" title="windowclipping-106" src="http://www.unauthorised-access.com/wp-content/uploads/2009/02/windowclipping-106.png" alt="windowclipping-106" width="397" height="172" /></p>
<p><img class="alignnone size-full wp-image-111" title="windowclipping-107" src="http://www.unauthorised-access.com/wp-content/uploads/2009/02/windowclipping-107.png" alt="windowclipping-107" width="462" height="118" /></p>
<p>And the page result is:</p>
<p><cite>abc                          12345<br />
def                          67890 </cite></p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/02/nesting-repeaters-without-onitemdatabound/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>Introduction to CSS Adapters &#8211; Label Control</title>
		<link>http://www.unauthorised-access.com/2008/11/introduction-to-css-adapters/</link>
		<comments>http://www.unauthorised-access.com/2008/11/introduction-to-css-adapters/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 12:53:00 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[CSSAdapter]]></category>
		<category><![CDATA[HtmlTextWriterTag]]></category>
		<category><![CDATA[RenderEndTag]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[WebControls]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=52</guid>
		<description><![CDATA[CSS Adapters in .net are rarely used, even though they are really powerful and can fix things like xhtml validation errors. This very quick sample will show you how to replace the &#60;span&#62; tags with a &#60;div&#62; Create a class file, something like &#8220;LabelOverride.cs&#8221;, and put in the following: Create a folder in the web [...]]]></description>
			<content:encoded><![CDATA[<p>CSS Adapters in .net are rarely used, even though they are really powerful and can fix things like xhtml validation errors. This very quick sample will show you how to replace the &lt;span&gt; tags with a &lt;div&gt;</p>
<p>Create a class file, something like &#8220;LabelOverride.cs&#8221;, and put in the following:</p>
<pre class="brush: csharp; title: ; notranslate">

using System.Web.UI;

namespace CSSAdapterTest
{
public class LabelOverride : System.Web.UI.WebControls.Adapters.WebControlAdapter
{
protected override void RenderBeginTag(HtmlTextWriter writer)
{
writer.RenderBeginTag(HtmlTextWriterTag.Div);
}
protected override void RenderEndTag(HtmlTextWriter writer)
{
writer.RenderEndTag();
}
}
}
</pre>
<p>Create a folder in the web application called &#8220;App_Browsers&#8221;, and create a .browsers file called &#8220;CSSAdapter.browser&#8221;, and enter in the following:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;browsers&gt;
&lt;browser refID=&quot;Default&quot;&gt;
&lt;controlAdapters&gt;
&lt;adapter controlType=&quot;System.Web.UI.WebControls.Label&quot;
adapterType=&quot;CSSAdapterTest.LabelOverride&quot; /&gt;
&lt;/controlAdapters&gt;
&lt;/browser&gt;
&lt;/browsers&gt;
</pre>
<p>This basically tells asp.net to override the controlType&#8217;s renderer with the one you have specified.</p>
<p>Once you have done this, and when you build your application, all &lt;span&gt;&#8217;s will disappear and be replaced with &lt;div&gt;&#8217;s!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2008/11/introduction-to-css-adapters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

