<?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>Infinities Loop</title><link>http://weblogs.asp.net/infinitiesloop/default.aspx</link><description>ASP.NET and .NET from a new perspective</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>ASP.NET 4.0 ScriptManager Improvements</title><link>http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager-improvements.aspx</link><pubDate>Tue, 24 Nov 2009 05:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7263952</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>18</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=7263952</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager-improvements.aspx#comments</comments><description>.NET Framework 4 Beta 2 has been out for a little while now. There are some subtle improvements to the ScriptManager control in ASP.NET 4.0 that few have picked up on yet. Allow me to introduce you to them! First, let me say that this is strictly about...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager-improvements.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7263952" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Script+Loading/default.aspx">Script Loading</category></item><item><title>Microsoft Ajax 4 Preview 5: The DataView Control</title><link>http://weblogs.asp.net/infinitiesloop/archive/2009/09/11/microsoft-ajax-4-preview-5-the-dataview-control.aspx</link><pubDate>Fri, 11 Sep 2009 20:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7200367</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>29</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=7200367</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2009/09/11/microsoft-ajax-4-preview-5-the-dataview-control.aspx#comments</comments><description>Preview 5 of the Microsoft Ajax 4.0 library has been released. Some quick background – this the next version of the client-side ajax framework you have probably already heard of, the one that ships along with ASP.NET 3.5 (but is also available in script...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2009/09/11/microsoft-ajax-4-preview-5-the-dataview-control.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7200367" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>ASP.NET WebForms: Taking Back the HTML</title><link>http://weblogs.asp.net/infinitiesloop/archive/2009/07/01/asp-net-webforms-taking-back-the-html.aspx</link><pubDate>Wed, 01 Jul 2009 23:44:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7138290</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>23</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=7138290</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2009/07/01/asp-net-webforms-taking-back-the-html.aspx#comments</comments><description>&lt;P&gt;There’s a lot of &lt;A href="http://weblogs.asp.net/jeff/archive/2009/06/23/webforms-vs-mvc-the-desire-to-rewrite-everything-an-unexpected-benefit.aspx" mce_href="http://weblogs.asp.net/jeff/archive/2009/06/23/webforms-vs-mvc-the-desire-to-rewrite-everything-an-unexpected-benefit.aspx"&gt;debate&lt;/A&gt; &lt;A href="http://www.hanselman.com/forum/messages.aspx?TopicID=251" mce_href="http://www.hanselman.com/forum/messages.aspx?TopicID=251"&gt;these&lt;/A&gt; &lt;A href="http://haacked.com/archive/2008/11/13/future-of-aspnet.aspx" mce_href="http://haacked.com/archive/2008/11/13/future-of-aspnet.aspx"&gt;days&lt;/A&gt; about the ASP.NET WebForms model vs. the newer ASP.NET MVC model. There are advantages to both. Disadvantages to both. Pick the one that best fits your needs. Nuff said. But sometimes that choice isn’t so obvious.&lt;/P&gt;
&lt;P&gt;MVC for example essentially gives you much more control over the generated HTML for the page. Well, complete control. But sometimes you don’t really need complete control, and the lack of an encapsulated control kind of sucks. HTML Helpers help, but they have no design time experience. Hence, there are the &lt;A href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471" target=_blank mce_href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471"&gt;MVC Controls in the MVC Futures project&lt;/A&gt; on CodePlex and an interesting compromise between the two models, at least when it comes to the rendering part of the application.&lt;/P&gt;
&lt;P&gt;But then there’s the other side of the equation – you’ve got a WebForms application, and you need a little more control over the HTML. What’s the compromise there? Well, server controls try to give you control over the markup. Some of them do a pretty good job at it, like the ListView control added in ASP.NET 3.5. Others, not so good. If a control doesn’t let you do what you need, you are pretty much stuck – either abandon the control and all its usefulness, or write your own control.&lt;/P&gt;
&lt;H1&gt;What’s in a control anyway?&lt;/H1&gt;
&lt;P&gt;If you think about it, controls at the highest level are really two very different things.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Controls abstract the rendering of HTML. &lt;/LI&gt;
&lt;LI&gt;Controls provide client-server integration by managing data between client and server. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Take the CheckBox control. It renders an input and label, and connects them with the ‘for’ attribute, so clicking the text also checks and unchecks the checkbox. That’s it’s HTML abstraction. It provides client-server integration by allowing you to dynamically read and write to the checked property on a server-side proxy.&lt;/P&gt;
&lt;P&gt;A simple example of #2 is the TextBox control. Double meaning, uh, not intended. Type some text into the box and submit the form – magically, the server-side instance knows what its Text property should do. The control can also push data back to the client. Set the Text property, and magically the value is reflected in the rendered page. This can be much more complex though – the control might manage a hidden field, or rely on data stored in that catch-all hidden field we &lt;A href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx" target=_blank mce_href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx"&gt;love to hate&lt;/A&gt;, ViewState.&lt;/P&gt;
&lt;P&gt;The thing is, HTML abstraction is useful, but a lot of the time it doesn’t provide a ton of benefit. Client-server integration, however, is usually much more useful. If you don’t need that there’s a good chance you don’t need a control to begin with.&lt;/P&gt;
&lt;H1&gt;Html Controls&lt;/H1&gt;
&lt;P&gt;I would be wrong not to point out that there’s a whole namespace of controls in ASP.NET that are largely underused. HTML controls allow you to add a runat=”server” to an HTML element and get reasonable client-server integration with it. So if you don’t like how the CheckBox control renders, just use the HtmlCheckBox instead. But what if you’re using a more complex control that has no HTML equivalent?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What if you could control the HTML for any server control without losing the client-server interaction?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Wouldn’t that be nice?&lt;/P&gt;
&lt;H1&gt;Taking Control&lt;/H1&gt;
&lt;P&gt;Introducing the &lt;STRONG&gt;CustomRender&lt;/STRONG&gt; control. This control suppresses the rendering of any control(s) you put in it, while allowing you to define your own, replacement HTML. It gets a little nicer than that, though. One step at a time – first, lets choose the enemy. A Button control that sets the text of a Label control.&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;script&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #3e60fd"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;void&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;ButtonClick&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #3e60fd"&gt;object&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;sender&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;args&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: white"&gt;Label1&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Text&lt;/SPAN&gt; &lt;SPAN style="COLOR: aqua"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;"You clicked Button1"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;script&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Button&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Button1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; Text&lt;SPAN style="COLOR: teal"&gt;="Go"&lt;/SPAN&gt; OnClick&lt;SPAN style="COLOR: teal"&gt;="ButtonClick"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Label&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Label1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;You’re going down, Button1.&lt;/STRONG&gt; Bring on the CustomRender:&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;i88&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;CustomRender&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Button&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Button1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; Text&lt;SPAN style="COLOR: teal"&gt;="Go"&lt;/SPAN&gt; OnClick&lt;SPAN style="COLOR: teal"&gt;="ButtonClick"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Label&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Label1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;i88&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;CustomRender&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;That’s step 1. Now how do we get our own HTML in here? As this stands, the button and label will not render anything. They still participate in the page lifecycle and all that goodness. But nothing renders. So we could just put the HTML next to the CustomRender control. But it would be nice if this control helped me out a little by giving me what these controls would have rendered, wouldn’t it? Lets swap over to Design View.&lt;/P&gt;
&lt;P&gt;If you’re one of the types that never uses Design View – it’s that button that says ‘Design’ on the lower left, or Shift-F7.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/infinitiesloop/image_58CF26C0.png" mce_href="http://weblogs.asp.net/blogs/infinitiesloop/image_58CF26C0.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_2EFB8600.png" width=608 height=483 mce_src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_2EFB8600.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Click on “Update HtmlTemplate”, then switch back on over to Source view. Voila…&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;i88&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;CustomRender&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Button&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Button1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; Text&lt;SPAN style="COLOR: teal"&gt;="Go"&lt;/SPAN&gt; OnClick&lt;SPAN style="COLOR: teal"&gt;="ButtonClick"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Label&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Label1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;HtmlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;input&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Button1"&lt;/SPAN&gt; name&lt;SPAN style="COLOR: teal"&gt;="Button1"&lt;/SPAN&gt; type&lt;SPAN style="COLOR: teal"&gt;="submit"&lt;/SPAN&gt; value&lt;SPAN style="COLOR: teal"&gt;="Go"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;span&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Label1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;span&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;HtmlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;i88&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;CustomRender&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;The designer for the control has rendered its ControlTemplate and put the result into the HtmlTemplate. And just to prove it works, modify the HTML a little. Lets change the ‘value’ of the input from ‘Go’ to ‘Gone’. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/infinitiesloop/image_6661972E.png" mce_href="http://weblogs.asp.net/blogs/infinitiesloop/image_6661972E.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_4BB4FB15.png" width=360 height=271 mce_src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_4BB4FB15.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;And now lets click the button and see if the server control still works. Remember, it’s supposed to set the text of the label to “You clicked Button1.”. Hmmmm.. nothing. It broke!!! No… remember, when you do this, you take complete control over the HTML. That text doesn’t just come from no where. The code is running, but you haven’t put it into your HTML.&lt;/P&gt;
&lt;P&gt;How do you do that? No problem – &lt;EM&gt;think of the HTML template like a mini-MVC View&lt;/EM&gt;.&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;HtmlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;input&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Button1"&lt;/SPAN&gt; name&lt;SPAN style="COLOR: teal"&gt;="Button1"&lt;/SPAN&gt; type&lt;SPAN style="COLOR: teal"&gt;="submit"&lt;/SPAN&gt; value&lt;SPAN style="COLOR: teal"&gt;="Gone"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;span&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="Label1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;Label1&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Text&lt;/SPAN&gt; &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;span&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;HtmlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Now when we click the button, it works:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/infinitiesloop/image_23361901.png" mce_href="http://weblogs.asp.net/blogs/infinitiesloop/image_23361901.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_21854D2D.png" width=360 height=271 mce_src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_21854D2D.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H1&gt;Show Off – The Challenge&lt;/H1&gt;
&lt;P&gt;“Okay,” you say, “but that’s just a button and a label. What about a real world scenario,” you spout in disbelief? I dunno if you said that, but it’s more interesting to pretend like you are challenging me to put this technique to the test. &lt;U&gt;I accept your pretend challenge&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;Way back in ASP.NET 1.x there was the DataGrid control. As great as it was at the time, it’s limitations eventually led to the GridView control. As great as &lt;EM&gt;that&lt;/EM&gt; was, you still didn’t get enough control over the markup and CSS, so the ListView control was born (I often wonder what we’d call the next iteration – running out of two-word data-like combinations aren’t we? No, there already is a DataList control!). My point being that in the current set of databound controls, the DataGrid control is probably the oldest and most set in its ways, and most known for its lack of customizability. It renders as a &amp;lt;Table&amp;gt;, and that’s that. How 1990’s of it.&lt;/P&gt;
&lt;P&gt;A perfect target for the challenge – let’s do the unthinkable. &lt;U&gt;Get a DataGrid to render as &amp;lt;UL&amp;gt; and &amp;lt;LI&amp;gt; and be styled with 100% CSS, while maintaining the server-side features like SelectedIndex&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;First, lets take a look at a DataGrid utilizing the SelectedIndex feature.&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;DataGrid&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="dg1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AutoGenerateColumns&lt;SPAN style="COLOR: teal"&gt;="false"&lt;/SPAN&gt; SelectedIndex&lt;SPAN style="COLOR: teal"&gt;="1"&lt;/SPAN&gt; SelectedItemStyle-CssClass&lt;SPAN style="COLOR: teal"&gt;="selected"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataSource&lt;SPAN style="COLOR: teal"&gt;='&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;# DummyData &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;BoundColumn&lt;/SPAN&gt; DataField&lt;SPAN style="COLOR: teal"&gt;="Name"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ButtonColumn&lt;/SPAN&gt; DataTextField&lt;SPAN style="COLOR: teal"&gt;="Price"&lt;/SPAN&gt; DataTextFormatString&lt;SPAN style="COLOR: teal"&gt;="{0:c}"&lt;/SPAN&gt; CommandName&lt;SPAN style="COLOR: teal"&gt;="Select"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;DataGrid&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;It shows two columns – a product name, and a price, formatted as currency. You can click on the price to select the item, which then has a different CSS class. The DummyData property is just returning an ArrayList with a few sample items. Let’s not forget how you databind this thing… you may be using a DataSource control. For this purpose we’ll just do it the old fashioned way.&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;protected&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;override&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;void&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;OnLoad&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;e&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #3e60fd"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: aqua"&gt;!&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Page&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;IsPostBack&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: white"&gt;dg1&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;DataBind&lt;/SPAN&gt;();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #3e60fd"&gt;base&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;OnLoad&lt;/SPAN&gt;(&lt;SPAN style="COLOR: white"&gt;e&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Now lets take a look at the rendering.&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;table&lt;/SPAN&gt; cellspacing&lt;SPAN style="COLOR: teal"&gt;="0"&lt;/SPAN&gt; rules&lt;SPAN style="COLOR: teal"&gt;="all"&lt;/SPAN&gt; border&lt;SPAN style="COLOR: teal"&gt;="1"&lt;/SPAN&gt; id&lt;SPAN style="COLOR: teal"&gt;="dg1"&lt;/SPAN&gt; style&lt;SPAN style="COLOR: teal"&gt;="&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;border-collapse&lt;/SPAN&gt;:&lt;SPAN style="COLOR: #3e60fd"&gt;collapse&lt;/SPAN&gt;;&lt;SPAN style="COLOR: teal"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;tr&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;tr&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;tr&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;Widget&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;a&lt;/SPAN&gt; href&lt;SPAN style="COLOR: teal"&gt;="javascript:__doPostBack('dg1$ctl02$ctl00','')"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;$19.95&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;a&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;tr&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;tr&lt;/SPAN&gt; class&lt;SPAN style="COLOR: teal"&gt;="selected"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;Horn&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;a&lt;/SPAN&gt; href&lt;SPAN style="COLOR: teal"&gt;="javascript:__doPostBack('dg1$ctl03$ctl00','')"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;$2.99&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;a&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;td&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;tr&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;table&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/infinitiesloop/image_3FEF8E16.png" mce_href="http://weblogs.asp.net/blogs/infinitiesloop/image_3FEF8E16.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_3A347470.png" width=425 height=357 mce_src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_3A347470.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;A few things of note going on here. For the SelectedIndex feature to work, the ButtonColumn has rendered an &amp;lt;A&amp;gt; tag which does a postback. The ID it passes to the __doPostBack function is the UniqueID of a link button it has added to the control tree. The LinkButton raises a bubble command named “Select”, which the DataGrid picks up and sets its SelectedIndex property. While rendering, the DataGrid applies a different style to the selected item.&lt;/P&gt;
&lt;P&gt;Translating this into your own custom HTML is pretty easy actually. The trick is to do rendering only – you could in theory use a Repeater to bind over the same items. We’re trying to leverage the existing features of the DataGrid, so rather than grab the data directly we’re enumerate the DataGrid’s Items collection and try to reuse as much as we can.&lt;/P&gt;
&lt;P&gt;Again, think of this template as a mini-MVC view, and the actual control we are targeting is like our ViewData. That way, changes to the DataGrid don’t require changes to the custom rendering.&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;i88&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;CustomRender&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="c1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;DataGrid&lt;/SPAN&gt; ID&lt;SPAN style="COLOR: teal"&gt;="dg1"&lt;/SPAN&gt; runat&lt;SPAN style="COLOR: teal"&gt;="server"&lt;/SPAN&gt; SelectedItemStyle-BackColor&lt;SPAN style="COLOR: teal"&gt;="Red"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AutoGenerateColumns&lt;SPAN style="COLOR: teal"&gt;="false"&lt;/SPAN&gt; SelectedIndex&lt;SPAN style="COLOR: teal"&gt;="1"&lt;BR&gt;            &lt;/SPAN&gt;SelectedItemStyle-CssClass&lt;SPAN style="COLOR: teal"&gt;="selected"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataSource&lt;SPAN style="COLOR: teal"&gt;='&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;# DummyData &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;BoundColumn&lt;/SPAN&gt; DataField&lt;SPAN style="COLOR: teal"&gt;="Name"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ButtonColumn&lt;/SPAN&gt; DataTextField&lt;SPAN style="COLOR: teal"&gt;="Price"&lt;BR&gt;                     &lt;/SPAN&gt;DataTextFormatString&lt;SPAN style="COLOR: teal"&gt;="{0:c}"&lt;/SPAN&gt; CommandName&lt;SPAN style="COLOR: teal"&gt;="Select"&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;Columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;DataGrid&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;HtmlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;for&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #3e60fd"&gt;int&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;i&lt;/SPAN&gt; &lt;SPAN style="COLOR: aqua"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: yellow"&gt;0&lt;/SPAN&gt;; &lt;SPAN style="COLOR: white"&gt;i&lt;/SPAN&gt; &lt;SPAN style="COLOR: aqua"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;dg1&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Items&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Count&lt;/SPAN&gt;; &lt;SPAN style="COLOR: white"&gt;i&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;++&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="BACKGROUND: #151515; COLOR: green"&gt;// enumerate the DataGrid's items so we can choose how to render them&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #3e60fd"&gt;var&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;item&lt;/SPAN&gt; &lt;SPAN style="COLOR: aqua"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;dg1&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Items&lt;/SPAN&gt;[&lt;SPAN style="COLOR: white"&gt;i&lt;/SPAN&gt;];&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="BACKGROUND: #151515; COLOR: green"&gt;// the ButtonColumn is rendering a LinkButton or Button &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #3e60fd"&gt;var&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;priceLink&lt;/SPAN&gt; &lt;SPAN style="COLOR: aqua"&gt;=&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;IButtonControl&lt;/SPAN&gt;)&lt;SPAN style="COLOR: white"&gt;item&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Cells&lt;/SPAN&gt;[&lt;SPAN style="COLOR: yellow"&gt;1&lt;/SPAN&gt;]&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Controls&lt;/SPAN&gt;[&lt;SPAN style="COLOR: yellow"&gt;0&lt;/SPAN&gt;];&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ul&lt;/SPAN&gt; class&lt;SPAN style="COLOR: teal"&gt;="item&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;= dg1.SelectedIndex == i ? " selected" : "" &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;item&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Cells&lt;/SPAN&gt;[&lt;SPAN style="COLOR: yellow"&gt;0&lt;/SPAN&gt;]&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Text&lt;/SPAN&gt; &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;li&lt;/SPAN&gt; class&lt;SPAN style="COLOR: teal"&gt;='price'&lt;/SPAN&gt; &lt;BR&gt;                onclick&lt;SPAN style="COLOR: teal"&gt;="&lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;= Page.GetPostBackEventReference((Control)priceLink) &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;BR&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: white"&gt;priceLink&lt;/SPAN&gt;&lt;SPAN style="COLOR: aqua"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: white"&gt;Text&lt;/SPAN&gt; &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;BR&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;ul&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: yellow"&gt;&amp;lt;%&lt;/SPAN&gt; } &lt;SPAN style="COLOR: yellow"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;HtmlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;i88&lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;CustomRender&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;A for loop enumerates the DataGrid.Items collection. For the first column we just repeat the cell’s text. The 2nd column is more complex as it contains a LinkButton with a postback reference. Even so, it’s not too complex – get a reference to the LinkButton and use Page.GetPostBackEventReference() to generate the necessary postback script. We are now free to apply CSS in anyway we like. Watching for the the SelectedIndex, we apply a ‘selected’ class, for example.&lt;/P&gt;
&lt;P&gt;I’ve just quickly put together these styles to make each ‘item’ float left, so the “grid” isn’t even a grid anymore, just to show how it can be totally different.&lt;/P&gt;
&lt;DIV class=codeSample&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;style&lt;/SPAN&gt; type&lt;SPAN style="COLOR: teal"&gt;="text/css"&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #a31515"&gt;ul.item&lt;/SPAN&gt; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: red"&gt;float&lt;/SPAN&gt;: &lt;SPAN style="COLOR: #3e60fd"&gt;left&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: red"&gt;list-style-type&lt;/SPAN&gt;: &lt;SPAN style="COLOR: #3e60fd"&gt;none&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: red"&gt;padding&lt;/SPAN&gt;: &lt;SPAN style="COLOR: #3e60fd"&gt;0px&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;10px&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;0px&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;10px&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #a31515"&gt;ul.selected&lt;/SPAN&gt; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: red"&gt;border&lt;/SPAN&gt;: &lt;SPAN style="COLOR: #3e60fd"&gt;solid&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;1px&lt;/SPAN&gt; &lt;SPAN style="COLOR: #3e60fd"&gt;red&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #a31515"&gt;li.price&lt;/SPAN&gt; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: red"&gt;cursor&lt;/SPAN&gt;: &lt;SPAN style="COLOR: #3e60fd"&gt;pointer&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: red"&gt;color&lt;/SPAN&gt;: &lt;SPAN style="COLOR: #3e60fd"&gt;Blue&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: red"&gt;text-decoration&lt;/SPAN&gt;: &lt;SPAN style="COLOR: #3e60fd"&gt;underline&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #3e60fd"&gt;style&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;And here it is running.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/infinitiesloop/image_3C8DF66E.png" mce_href="http://weblogs.asp.net/blogs/infinitiesloop/image_3C8DF66E.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_41FC6712.png" width=425 height=357 mce_src="http://weblogs.asp.net/blogs/infinitiesloop/image_thumb_41FC6712.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H1&gt;Mission Accomplished&lt;/H1&gt;
&lt;P&gt;Perhaps you are thinking that is pretty ugly and difficult. If you are, remember that is why controls abstract that stuff away for you, so it’s easy and expressive. This is by no means “the end” of control rendering. It’s a tool you should keep in your toolbox. If you have a difficult to fix rendering issue for a specific control, now you don’t have to say goodbye to the whole thing.&lt;/P&gt;
&lt;H1&gt;How does it work?&lt;/H1&gt;
&lt;P&gt;It’s actually pretty simple! All controls create their HTML in the Render() method. To control the HTML, you just need a way of injecting your own HTML while suppressing the stuff it’s Render() method produces. Ok – so, &lt;EM&gt;don’t call Render()&lt;/EM&gt;. The Render method unfortunately does not only produce HTML. Sometimes it produces script references or “startup” scripts. Sometimes it registers with the ASP.NET Event Validation feature for security purposes. So this control still calls Render, but it throws away the resulting HTML. It instantiates the ControlTemplate like any other template, adding it to its own control tree so they particulate in the lifecycle. It just chooses to actually render the HTML template instead. That is, unless it is design time. Then it renders the control template – allowing you to use the controls in the designer like you normally could.&lt;/P&gt;
&lt;H1&gt;Gotchas&lt;/H1&gt;
&lt;P&gt;Controls will not necessarily take kindly to being rendered “for reals” at Design Time. The page isn’t real, and the other controls on the page don’t necessarily exist or are in their proper hierarchy. So the “Update HtmlTemplate” designer action may not always work. It might even cause an exception to be thrown. It depends on the control.&lt;/P&gt;
&lt;P&gt;Also, I find that although the correct HTML is being rendered internally, VS gets it’s hands on it and makes a few modifications to the persistence of it for some reason. It seems mostly benign, like reordering element attributes. But one bad thing it does is capitalize the ‘id’ attribute, which is supposed to be in lower case if you care about XHTML compliance. Easy enough to fix once you get the HTML bootstrapped. I’m trying to find out from someone on the team why this happens and if we can fix it. If all else fails, you can always run the page and use the actual source to get the HTML rather than use the designer trick.&lt;/P&gt;
&lt;H1&gt;Download &amp;amp; Discuss&lt;/H1&gt;
&lt;P&gt;It’s up on code gallery, including the sample of the world’s first cannibalized DataGrid.&lt;/P&gt;
&lt;P&gt;&lt;A title=http://code.msdn.microsoft.com/aspnetcustomrender href="http://code.msdn.microsoft.com/aspnetcustomrender" mce_href="http://code.msdn.microsoft.com/aspnetcustomrender"&gt;http://code.msdn.microsoft.com/aspnetcustomrender&lt;/A&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7138290" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/HTML/default.aspx">HTML</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/MVC/default.aspx">MVC</category></item><item><title>Professional ASP.NET 3.5 AJAX Released</title><link>http://weblogs.asp.net/infinitiesloop/archive/2009/02/10/professional-asp-net-3-5-ajax-released.aspx</link><pubDate>Tue, 10 Feb 2009 23:35:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6897200</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6897200</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2009/02/10/professional-asp-net-3-5-ajax-released.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;Looking for an ASP.NET AJAX book? This one has been massively updated from its 2.0 version, to cover in detail the features added in 3.5, and not to be forgotten, 3.5 SP1. For example, Script Combining was a new feature in 3.5 SP1, and so was History support, so it's an important distinction! The 2.0 book was 307 pages, and this one is 552. History support, by the way, has a dedicated chapter. Script combining is a major portion of the chapter on the ScriptManager.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;Another important difference between the 2.0 and 3.5 versions -- this time, I'm a contributing author. :) My first major technical publication, hopefully more to come. I'm that weird guy on the right.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.amazon.com/Professional-ASP-NET-AJAX-Bill-Evjen/dp/0470392177" target=_blank mce_href="http://www.amazon.com/Professional-ASP-NET-AJAX-Bill-Evjen/dp/0470392177"&gt;&lt;IMG border=0 src="http://www.infinity88.com/images/blog/ASPNET35AJAX.jpg" mce_src="http://www.infinity88.com/images/blog/ASPNET35AJAX.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;&lt;A href="http://www.amazon.com/Professional-ASP-NET-AJAX-Bill-Evjen/dp/0470392177" target=_blank mce_href="http://www.amazon.com/Professional-ASP-NET-AJAX-Bill-Evjen/dp/0470392177"&gt;http://www.amazon.com/Professional-ASP-NET-AJAX-Bill-Evjen/dp/0470392177&lt;/A&gt; &lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6897200" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category></item><item><title>The Event Handler That Cried Wolf</title><link>http://weblogs.asp.net/infinitiesloop/archive/2009/01/14/the-event-handler-that-cried-wolf.aspx</link><pubDate>Wed, 14 Jan 2009 16:00:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6835068</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>20</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6835068</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2009/01/14/the-event-handler-that-cried-wolf.aspx#comments</comments><description>I ran into an interesting and unexpected behavior in ASP.NET AJAX event handling the other day. Once I figured out what was going on, I was almost positive it was a bug, so I started looking into what a solution would be. But just out of curiosity, I...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2009/01/14/the-event-handler-that-cried-wolf.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6835068" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category></item><item><title>ASP.NET AJAX 4.0: Observing updates to POJOs (Plain 'Ole JavaScript Objects)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/11/09/asp-net-ajax-4-0-observing-updates-to-pojos-plain-ole-javascript-objects.aspx</link><pubDate>Mon, 10 Nov 2008 07:27:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6728228</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>29</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6728228</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/11/09/asp-net-ajax-4-0-observing-updates-to-pojos-plain-ole-javascript-objects.aspx#comments</comments><description>First of all, if you haven't already done so, download the ASP.NET AJAX 4.0 Preview 3 now and try it out! And after you're done with that, come back here, or there , or there , or there , and let us know what you think and what you like or don't like...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/11/09/asp-net-ajax-4-0-observing-updates-to-pojos-plain-ole-javascript-objects.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6728228" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Google Chrome - Aw, Snap!</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/09/03/google-chrome-aw-snap.aspx</link><pubDate>Thu, 04 Sep 2008 05:32:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6597803</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6597803</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/09/03/google-chrome-aw-snap.aspx#comments</comments><description>Plenty of people have already seen this... interesting... error screen in chrome. I wanted to see what a run-away script would do to Chrome. There's always a warning that the script is taking too long, giving you a chance to shut it down. Here's what...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/09/03/google-chrome-aw-snap.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6597803" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Visual Studio Tip: Disable F1!</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/07/18/visual-studio-tip-disable-f1.aspx</link><pubDate>Fri, 18 Jul 2008 20:35:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6417150</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6417150</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/07/18/visual-studio-tip-disable-f1.aspx#comments</comments><description>Lately I've been using a laptop more often than a desktop to work in Visual Studio, and of course like most laptop keyboards, the keys are jammed close together. The most annoying thing I keep doing by mistake is hitting F1 instead of Escape, which of...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/07/18/visual-studio-tip-disable-f1.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6417150" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Coding+Environment/default.aspx">Coding Environment</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Keyboard/default.aspx">Keyboard</category></item><item><title>My Latest Work</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/06/17/my-latest-work.aspx</link><pubDate>Wed, 18 Jun 2008 04:18:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6288949</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>21</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6288949</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/06/17/my-latest-work.aspx#comments</comments><description>Sky Lynn Reed's 0th birthday is 5/15/2008 at 5:44pm, when she weighed 8 pounds, 0 ounces. A nice round binary number. Our first born! There are simply no words to describe the experience. We debated on whether we should have kids for a long time. After...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/06/17/my-latest-work.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6288949" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Musings/default.aspx">Musings</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Off+Topic/default.aspx">Off Topic</category></item><item><title>Flickering UI From the ASP.NET AJAX Toolkit TabContainer while in an UpdatePanel?</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/04/30/flickering-ui-from-the-asp-net-ajax-toolkit-tabcontainer-while-in-an-updatepanel.aspx</link><pubDate>Wed, 30 Apr 2008 18:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6145452</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>18</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6145452</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/04/30/flickering-ui-from-the-asp-net-ajax-toolkit-tabcontainer-while-in-an-updatepanel.aspx#comments</comments><description>UPDATE This issue is officially fixed in .NET 3.5 SP1. If you have applied the workaround in this blog post, you no longer need it. But the story of this bug is still rather interesting. UPDATE If you upgrade from Microsoft ASP.NET AJAX Extensions 1.0...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/04/30/flickering-ui-from-the-asp-net-ajax-toolkit-tabcontainer-while-in-an-updatepanel.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6145452" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Script+Loading/default.aspx">Script Loading</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/HTML/default.aspx">HTML</category></item><item><title>TRULY Understanding Dynamic Controls by Example</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/04/23/truly-understanding-dynamic-controls-by-example.aspx</link><pubDate>Wed, 23 Apr 2008 07:53:17 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6123575</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6123575</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/04/23/truly-understanding-dynamic-controls-by-example.aspx#comments</comments><description>Many of the comments I've received in the various dynamic controls entries I've written have been questions for help with a specific scenario. A lot of those scenarios are similar. One in particular I keep hearing is something as follows: The user is...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/04/23/truly-understanding-dynamic-controls-by-example.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6123575" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ViewState/default.aspx">ViewState</category></item><item><title>OnLoad vs. Page_Load vs. Load event</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/03/24/onload-vs-page-load-vs-load-event.aspx</link><pubDate>Tue, 25 Mar 2008 02:32:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6021600</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=6021600</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/03/24/onload-vs-page-load-vs-load-event.aspx#comments</comments><description>I get this question a lot for some reason. The more general question is whether it is better to override a virtual method on the page or control in question (OnLoad, OnInit, OnPreRender, etc), or to hook into the corresponding event . For page development...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/03/24/onload-vs-page-load-vs-load-event.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6021600" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Musings/default.aspx">Musings</category></item><item><title>TRULY Understanding ViewState, the comment index</title><link>http://weblogs.asp.net/infinitiesloop/archive/2008/02/19/truly-understanding-viewstate-comment-index.aspx</link><pubDate>Wed, 20 Feb 2008 05:23:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5825826</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=5825826</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2008/02/19/truly-understanding-viewstate-comment-index.aspx#comments</comments><description>A long time ago I published one of my first blog entries, TRULY Understanding ViewState . And what an experience it has been. It was pretty popular with commenters, so much so I decided to spin off a whole series of articles, TRULY Understanding Dynamic...(&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2008/02/19/truly-understanding-viewstate-comment-index.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5825826" width="1" height="1"&gt;</description><enclosure url="http://weblogs.asp.net/infinitiesloop/attachment/5825826.ashx" length="641536" type="application/msword" /><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ViewState/default.aspx">ViewState</category></item><item><title>ASP.NET Futures: Intro to the Xaml and Media Controls</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/11/12/asp-net-futures-intro-to-the-xaml-and-media-controls.aspx</link><pubDate>Tue, 13 Nov 2007 01:46:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5107729</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=5107729</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2007/11/12/asp-net-futures-intro-to-the-xaml-and-media-controls.aspx#comments</comments><description>&lt;P&gt;Still relatively unknown, &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a5189bcb-ef81-4c12-9733-e294d13a58e6&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a5189bcb-ef81-4c12-9733-e294d13a58e6&amp;amp;displaylang=en"&gt;ASP.NET Futures&lt;/A&gt; is a nice little add-on to ASP.NET and ASP.NET AJAX that contains some features we want public feedback on. It's a playground in which technology gets to frolic in front of the public's (your) eyes. So why not seize the opportunity to play with the bits and submit your thumbs up, thumbs down?&lt;/P&gt;
&lt;P&gt;I thought I'd give an introduction to two of the controls in ASP.NET Futures that I'm most fond of (I've worked on them, so I'm a little bit partial). If you already know about them, excellent, please log in some feedback.&lt;/P&gt;
&lt;H3&gt;&amp;lt;asp:Xaml runat="server" /&amp;gt;&lt;/H3&gt;
&lt;P&gt;The Xaml control is an integration story between Silverlight and ASP.NET. If you are writing ASP.NET pages that contain Silverlight content, especially if you are also using AJAX features, it's definitely worth a look. Because it's not only an integration of Silverlight and ASP.NET, but between Silverlight and ASP.NET AJAX. It defines a new client-side ajax type, Sys.Preview.UI.Xaml.Control. So, if you are familiar with ASP.NET and with ASP.NET AJAX, this control gives you a logical extension. Just point the control at a XAML resource, and it wraps an ajax type around Silverlight, giving you a familiar and object-oriented asp.net ajax programming model to work with the surface area between the HTML page and the Silverlight plugin instance.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://quickstarts.asp.net/Futures/Silverlight/xaml.aspx" target=_blank mce_href="http://quickstarts.asp.net/Futures/Silverlight/xaml.aspx"&gt;Take a look&lt;/A&gt; at a Calculator implemented using the Xaml control.&lt;/P&gt;
&lt;H3&gt;&amp;lt;asp:Media runat="server" /&amp;gt;&lt;/H3&gt;
&lt;P&gt;I said it is object oriented, and it is. The media control defines another client-side ajax type which derives from the first: Sys.Preview.UI.Xaml.Media.Player. When this type wraps a Silverlight plug-in, it does a lot of work to it, searching within the Xaml document for elements of certain predetermined names like "PlayButton", and makes them more than just a pretty Canvas by adding behavior to them implied by their name. It may seem trivial, but there are &lt;EM&gt;a lot&lt;/EM&gt; of subtle things that must happen to make what is essentially static markup (the xaml) behave like a full-blown media player. Silverlight makes it look pretty. The Media control brings it to life.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Not just a black box&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;When you watch video on a web page, you probably don't expect much in the way of interaction between the video and the page. The video is like a rich island in the middle of boring HTML, and never the twain shall meet. Even the orientation of the video is pretty much fixed -- ever seen a movie playing on a webpage at at 15 degree angle? I haven't. I'm not sure I want to, but I sure haven't!&lt;/P&gt;
&lt;P&gt;But it doesn't have to be that way... The media control exposes some pretty cool client-side APIs in the form of properties and events that allow for some really interesting interaction between the media and the rest of the page. asp:Media... Tearing down walls!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://quickstarts.asp.net/Futures/Silverlight/media.aspx" target=_blank mce_href="http://quickstarts.asp.net/Futures/Silverlight/media.aspx"&gt;Take a look&lt;/A&gt; at some of the cool things you can do with it.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Not just for fun, either&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The Media control can work with any Xaml. It's very forgiving with which Xaml elements it requires, too. What? Your Xaml doesn't have a MuteButton? Ok, no problem. But it does have a WizzyWigDoSomethingButton -- well, it doesn't know what that is, but a client-side type you create that derives from the media player's client side type knows what to do with it.&lt;/P&gt;
&lt;P&gt;The only element required is the MediaElement. Yeah you kind of need that one...&lt;/P&gt;
&lt;P&gt;You get the picture. But what most people don't know, even those who use it, is that the client-side code that drives the Media control has already appeared in many places. So many, in fact, that if you've seen video playing in Silverlight, you've probably executed the code. The code was joint developed and is shared by the Expression Encoder product, which allows you to export videos to html for execution in Silverlight. It too creates nice media player functionality in Silverlight... and it does it using the exact same code the Media control uses. Well, the namespace is different. But that's it.&lt;/P&gt;
&lt;P&gt;Here are some examples of sites using the Media control's client-side ajax type. Note how vastly different they look and behave -- a testament to Silverlight and this control.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://halo3.msn.com/videosHD.aspx" target=_blank mce_href="http://halo3.msn.com/videosHD.aspx"&gt;Halo 3 on MSN&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://silverlight.net/learn/learnvideos.aspx" target=_blank mce_href="http://silverlight.net/learn/learnvideos.aspx"&gt;The Silverlight Learning Videos&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/silverlight/" target=_blank mce_href="http://www.microsoft.com/silverlight/"&gt;Silverlight on Microsoft.com&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://channel9.msdn.com/" target=_blank mce_href="http://channel9.msdn.com/"&gt;The Channel 8 and Channel 9 Video Players&lt;/A&gt;&lt;BR&gt;(hear about this one &lt;A href="http://channel9.msdn.com/showpost.aspx?postid=344297" target=_blank mce_href="http://channel9.msdn.com/showpost.aspx?postid=344297"&gt;here&lt;/A&gt;. Favorite quote, "It seems almost too easy...")&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.clarkezone.net/" target=_blank mce_href="http://www.clarkezone.net/"&gt;James Clarke's Weblog&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;So there you have it. If you want to play video or audio on your site using Silverlight, and you don't want to implement an entire media player UI from scratch, have a look-see.&lt;/P&gt;
&lt;P&gt;EDIT: Hey, my first post tagged "Silverlight". Expect more in the future.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5107729" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Migraine m = (Migraine) DiagnosisFactory.Diagnose(pain)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/11/05/migraine-m-migraine-diagnosisfactory-diagnose-pain.aspx</link><pubDate>Tue, 06 Nov 2007 02:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:4914103</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/infinitiesloop/rsscomments.aspx?PostID=4914103</wfw:commentRss><comments>http://weblogs.asp.net/infinitiesloop/archive/2007/11/05/migraine-m-migraine-diagnosisfactory-diagnose-pain.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;I've struggled with pretty bad headaches probably ever since high school. They come and go with intensity and frequency. Sometimes I think I have them figured out. Eat right, and before I get starving, get enough sleep, and they usually leave me alone. But stressful times, like long business trips or big presentations, or other matters, can easily prompt one. I've grown so used to them that I always make sure I have a supply of Excedrin nearby. There's a bottle at home, up and down stairs, at work, even in the car for those unexpected times. I even have family members be sure to have a stock if I know I'll be visiting for an extended period of time.&lt;/P&gt;
&lt;P mce_keep="true"&gt;For whatever reason, Excedrin seems to be the only thing that helps. Nothing else even touches my headaches. But sometimes, on rare occasions, even Excedrin fails. Today was one of those times.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Bad enough that I finally went to a doctor about it (I was lucky to get a walk-in appointment). After describing all my symptoms, sure enough, these Excedrin-immune headaches are the migraine variety.&lt;/P&gt;
&lt;P mce_keep="true"&gt;If you've had a migraine, I need not explain how terrible they are. If you're one of the lucky ones&amp;nbsp;who don't get them, well, for me they on par with a really bad hangover.&lt;/P&gt;
&lt;P mce_keep="true"&gt;There are lots of options these days&amp;nbsp;for&amp;nbsp;dealing with&amp;nbsp;them. The key is preventing them by understanding what triggers them for you. I've lived with them all my life so far because they crept up on me. I never thought they were migraines because descriptions I read of them seem much more severe than what I have. Indeed I do seem to be luckier than most migraine sufferers -- they are bad, but not so bad that I must lock myself in a dark room for two days. Just thought I'd share my experience -- I'm sure lots of you can relate!&lt;/P&gt;
&lt;P mce_keep="true"&gt;Perhaps this is one sub-conscious reason why I prefer &lt;A class="" href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/06/Join-the-Dark-Side-of-Visual-Studio.aspx" target=_blank mce_href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/06/Join-the-Dark-Side-of-Visual-Studio.aspx"&gt;The Dark Side of Visual Studio&lt;/A&gt;. The bright light of the normal color scheme is just too overpowering.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=4914103" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/infinitiesloop/archive/tags/Off+Topic/default.aspx">Off Topic</category></item></channel></rss>