<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>this.Reflect()</title>
	
	<link>http://blog.donnfelker.com</link>
	<description>The Technology Blog of Donn Felker</description>
	<lastBuildDate>Tue, 16 Mar 2010 12:54:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/donnfelker" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="donnfelker" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>WP7 Emulator Screen Size Management</title>
		<link>http://blog.donnfelker.com/2010/03/16/wp7-emulator-screen-size-management/</link>
		<comments>http://blog.donnfelker.com/2010/03/16/wp7-emulator-screen-size-management/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 12:54:49 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/?p=406</guid>
		<description><![CDATA[I&#8217;ve been developing Android apps for awhile now and at times the emulators are SOOO big that they litterally consume the entire screen real estate and its very difficult to navigate through the enumlator. I was very surprised when I started up the WP7 emulator and started finding out how simple it was to scale <a href="http://blog.donnfelker.com/2010/03/16/wp7-emulator-screen-size-management/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/Small50Percent.png"></a>I&#8217;ve been developing Android apps for awhile now and at times the emulators are SOOO big that they litterally consume the entire screen real estate and its very difficult to navigate through the enumlator. I was very surprised when I started up the WP7 emulator and started finding out how simple it was to scale the emulator to fit my screen.</p>
<p>All I had to do was select the settings:</p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/Settings2.png"><img class="alignnone size-medium wp-image-409" title="Settings" src="http://blog.donnfelker.com/wp-content/uploads/2010/03/Settings2-199x300.png" alt="" width="199" height="300" /></a><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/Settings.png"></a></p>
<p>Then, select the screen size I wanted:</p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/screensize.png"><img class="alignnone size-medium wp-image-410" title="screensize" src="http://blog.donnfelker.com/wp-content/uploads/2010/03/screensize-172x300.png" alt="" width="172" height="300" /></a></p>
<p>The screen could scale accordingly now.</p>
<h2>Examples</h2>
<p>100% (Very Large) &#8211; Its so big that it falls off the screen.</p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/VeryBig100Percent.png"><img class="alignnone size-medium wp-image-412" title="VeryBig100Percent" src="http://blog.donnfelker.com/wp-content/uploads/2010/03/VeryBig100Percent-231x300.png" alt="" width="231" height="300" /></a></p>
<p>50% (Smaller), now it fits nicely, however the UI is hard to read.</p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/Small50Percent.png"><img title="Small50Percent" src="http://blog.donnfelker.com/wp-content/uploads/2010/03/Small50Percent-165x300.png" alt="" width="165" height="300" /></a></p>
<p>This makes life much easier when developing for a high resolution system on a non-high resoution system.</p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/Settings1.png"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/03/16/wp7-emulator-screen-size-management/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WP7 Boot to VHD</title>
		<link>http://blog.donnfelker.com/2010/03/15/wp7-boot-to-vh/</link>
		<comments>http://blog.donnfelker.com/2010/03/15/wp7-boot-to-vh/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 04:38:57 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/?p=402</guid>
		<description><![CDATA[Tonigt I downloaded the WP7 Developer Tools on a new VHD (Boot to VHD). I&#8217;d I&#8217;d have to say &#8230; its super easy.
File &#8211;&#62; New
As soon as the tools are installed you can select File &#8211;&#62; New Windows Phone Application, as seen below:

Selecting a new Phone app, I was able to get some XAML on <a href="http://blog.donnfelker.com/2010/03/15/wp7-boot-to-vh/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Tonigt I downloaded the <a href="http://developer.windowsphone.com">WP7 Developer Tools</a> on a new VHD (<a href="http://www.hanselman.com/blog/LessVirtualMoreMachineWindows7AndTheMagicOfBootToVHD.aspx">Boot to VHD</a>). I&#8217;d I&#8217;d have to say &#8230; its super easy.</p>
<h2>File &#8211;&gt; New</h2>
<p>As soon as the tools are installed you can select File &#8211;&gt; New Windows Phone Application, as seen below:</p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/newPHone.png"><img class="alignnone size-medium wp-image-403" title="File New" src="http://blog.donnfelker.com/wp-content/uploads/2010/03/newPHone-300x190.png" alt="File New" width="300" height="190" /></a></p>
<p>Selecting a new Phone app, I was able to get some XAML on the screen, edit the XAML and get my first Hello WP7 app up in running in under 5 minutes. This very impressive. The emulator started right up, I waited for about 30 seconds while it booted and then my app started. As shown below:</p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/HelloWP7.png"><img class="alignnone size-medium wp-image-404" title="Hello WP7" src="http://blog.donnfelker.com/wp-content/uploads/2010/03/HelloWP7-300x187.png" alt="Hellow WP7" width="300" height="187" /></a></p>
<p>All in all, it was a super simple process.</p>
<h2>Boot to VHD</h2>
<p>It is important to note that working from a virtualized environment is not supported with the Dev Tools for WP7. However, you can <a href="http://www.hanselman.com/blog/LessVirtualMoreMachineWindows7AndTheMagicOfBootToVHD.aspx">boot to vhd</a> and it will work great (which is 10x better than a VPC in my opinion for regular dev anyway).</p>
<p>So if you havent already, start utilizing Boot to VHD, set a a new one and get started with the new WP7 tools. Its cool/fun stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/03/15/wp7-boot-to-vh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC REST API WINDSOR CONTROLLER FACTORY</title>
		<link>http://blog.donnfelker.com/2010/03/11/aspnet-rest-controller-factory/</link>
		<comments>http://blog.donnfelker.com/2010/03/11/aspnet-rest-controller-factory/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 14:52:44 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC2]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/?p=398</guid>
		<description><![CDATA[I’m using the ASP.NET MVC REST Toolkit for a REST API I’m building for a mobile infrastructure. Long story short, it will be responsible for service hundreds of thousands (if not millions) of users through their mobile phones and rich applications (Android, iPhone and eventually the WP7 Phones).
The one thing that the Toolkit did not <a href="http://blog.donnfelker.com/2010/03/11/aspnet-rest-controller-factory/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I’m using the <a href="http://aspnet.codeplex.com/releases/view/24471" target="_blank">ASP.NET MVC REST Toolkit</a> for a REST API I’m building for a mobile infrastructure. Long story short, it will be responsible for service hundreds of thousands (if not millions) of users through their mobile phones and rich applications (Android, iPhone and eventually the WP7 Phones).</p>
<p>The one thing that the Toolkit did not provide out of the box was a way to use a container in the controller factory. Therefore I altered the ResourceControllerFactory to use <a href="http://www.castleproject.org" target="_blank">Windsor Container</a> as its default container. The code works great and I’m able to utilize dependency injection all throughout my app now.</p>
<p>The code for this is below:</p>
<pre class="brush: csharp;">
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//----------------------------------------------------------------

using Castle.MicroKernel;

namespace System.Web.Mvc.Resources
{
    using System.Collections.Generic;
    using System.Globalization;
    using System.Net;
    using System.Net.Mime;
    using System.Text;
    using System.Web.Routing;

    /// &lt;summary&gt;
    /// Specialized ControllerFactory that augments the base controller factory to make it RESTful - specifically, adding
    /// support for multiple formats, HTTP method based dispatch to controller methods and HTTP error handling
    /// &lt;/summary&gt;
    public class ResourceControllerFactory : IControllerFactory
    {
        // Note: This has been changed from the regular controller factory provided
        // by the ASP.NET Team so that we can use Windsor Container to resolve
        // container dependencies.

        readonly IKernel _kernel;
        const string restActionToken = &quot;$REST$&quot;;

        public ResourceControllerFactory(IKernel kernel)
        {
            _kernel = kernel;
        }

        public IController CreateController(RequestContext requestContext, string controllerName)
        {
            IController ic = _kernel.Resolve&lt;IController&gt;(controllerName.ToLowerInvariant() + &quot;controller&quot;);
            Controller c = ic as Controller;
            if (c != null &amp;&amp; WebApiEnabledAttribute.IsDefined(c))
            {
                IActionInvoker iai = c.ActionInvoker;
                ControllerActionInvoker cai = iai as ControllerActionInvoker;
                if (cai != null)
                {
                    c.ActionInvoker = new ResourceControllerActionInvoker();

                    string actionName = requestContext.RouteData.Values[&quot;action&quot;] as string;
                    if (string.IsNullOrEmpty(actionName))
                    {
                        // set it to a well known dummy value to avoid not having an action as that would prevent the fixup
                        // code in ResourceControllerActionInvoker, which is based on ActionDescriptor, from running
                        requestContext.RouteData.Values[&quot;action&quot;] = restActionToken;
                    }
                }
            }
            return ic;
        }

        public void ReleaseController(IController controller)
        {
            _kernel.ReleaseComponent(controller);
        }

        // This ActionInvoker allows us to dispatch to a controller when no action was provided by the routing
        // infrastructure, but the information is available in the request's HTTP verb (GET/PUT/POST/DELETE)
        class ResourceControllerActionInvoker : ControllerActionInvoker
        {
            public ResourceControllerActionInvoker()
            {
            }

            protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName)
            {
                if (actionName == restActionToken)
                {
                    // cleanup the restActionToken we set earlier
                    controllerContext.RequestContext.RouteData.Values[&quot;action&quot;] = null;

                    List&lt;ActionDescriptor&gt; matches = new List&lt;ActionDescriptor&gt;();
                    foreach (ActionDescriptor ad in controllerDescriptor.GetCanonicalActions())
                    {
                        object[] acceptVerbs = ad.GetCustomAttributes(typeof(AcceptVerbsAttribute), false);
                        if (acceptVerbs.Length &gt; 0)
                        {
                            foreach (object o in acceptVerbs)
                            {
                                AcceptVerbsAttribute ava = o as AcceptVerbsAttribute;
                                if (ava != null)
                                {
                                    if (ava.Verbs.Contains(controllerContext.RequestContext.GetHttpMethod().ToUpperInvariant()))
                                    {
                                        matches.Add(ad);
                                    }
                                }
                            }
                        }
                    }
                    switch (matches.Count)
                    {
                        case 0:
                            break;
                        case 1:
                            ActionDescriptor ad = matches[0];
                            actionName = ad.ActionName;
                            controllerContext.RequestContext.RouteData.Values[&quot;action&quot;] = actionName;
                            return ad;
                        default:
                            StringBuilder matchesString = new StringBuilder(matches[0].ActionName);
                            for (int index = 1; index &lt; matches.Count; index++)
                            {
                                matchesString.Append(&quot;, &quot;);
                                matchesString.Append(matches[index].ActionName);
                            }
                            return new ResourceErrorActionDescriptor(controllerDescriptor, HttpStatusCode.Conflict, string.Format(CultureInfo.CurrentCulture, &quot;Error dispatching on controller {0}, conflicting actions matched: (1)&quot;, controllerDescriptor.ControllerName, matchesString.ToString()));
                    }
                }
                return base.FindAction(controllerContext, controllerDescriptor, actionName) ??
                    new ResourceErrorActionDescriptor(controllerDescriptor, HttpStatusCode.NotFound, string.Format(CultureInfo.CurrentCulture, &quot;Error dispatching on controller {0}, no actions matched&quot;, controllerDescriptor.ControllerName));
            }

            // This class is used when we don't find an ActionDescriptor or find multiple matches
            // in this case we want to return an error response but throwing an HttpException from
            // FindAction bypasses the InvokeExceptionFilters, so instead we throw in this custom ActionDescriptor
            class ResourceErrorActionDescriptor : ActionDescriptor
            {
                ControllerDescriptor controllerDescriptor;
                string message;
                HttpStatusCode statusCode;

                public ResourceErrorActionDescriptor(ControllerDescriptor controllerDescriptor, HttpStatusCode statusCode, string message)
                {
                    this.message = message;
                    this.statusCode = statusCode;
                    this.controllerDescriptor = controllerDescriptor;
                }

                public override string ActionName
                {
                    get { return restActionToken; }
                }

                public override ControllerDescriptor ControllerDescriptor
                {
                    get { return this.controllerDescriptor; }
                }

                public override object Execute(ControllerContext controllerContext, IDictionary&lt;string, object&gt; parameters)
                {
                    HttpException he = new HttpException((int)this.statusCode, this.message);
                    ResourceErrorActionResult rear;
                    if (!WebApiEnabledAttribute.TryGetErrorResult2(controllerContext.RequestContext, he, out rear))
                    {
                        rear = new ResourceErrorActionResult(new HttpException((int)this.statusCode, this.message), new ContentType(&quot;text/plain&quot;));
                    }
                    return rear;
                }

                public override ParameterDescriptor[] GetParameters()
                {
                    return new ParameterDescriptor[0];
                }
            }
        }
    }
}
</pre>
<p>You can easily replace the Windsor stuff with StructureMap, NInject, Autofac, etc.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/03/11/aspnet-rest-controller-factory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slides from MVC2 Talk</title>
		<link>http://blog.donnfelker.com/2010/03/07/slides-from-mvc2-talk/</link>
		<comments>http://blog.donnfelker.com/2010/03/07/slides-from-mvc2-talk/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 17:13:08 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/?p=393</guid>
		<description><![CDATA[I apologize for being a bit late on posting these &#8230;
Here are the slides from last Thursday&#8217;s &#8220;What&#8217;s New in MVC2&#8221; talk at the Twin Cities .NET User Group Meeting.
Download Slides
]]></description>
			<content:encoded><![CDATA[<p>I apologize for being a bit late on posting these &#8230;</p>
<p>Here are the slides from last Thursday&#8217;s &#8220;<em>What&#8217;s New in MVC2</em>&#8221; talk at the Twin Cities .NET User Group Meeting.</p>
<h3><a href="http://blog.donnfelker.com/wp-content/uploads/2010/03/WhatsNewInAspnetmvc2.pptx">Download Slides</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/03/07/slides-from-mvc2-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I’m a Considered a Top Android Dev, Cool!</title>
		<link>http://blog.donnfelker.com/2010/03/04/im-a-considered-a-top-android-dev-cool/</link>
		<comments>http://blog.donnfelker.com/2010/03/04/im-a-considered-a-top-android-dev-cool/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 14:13:50 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/2010/03/04/im-a-considered-a-top-android-dev-cool/</guid>
		<description><![CDATA[This last Tuesday I received an email from the Android Market Seeding Program letting me know the following: 
Due to your contribution to the success of Android Market, we would like to present you with a brand new Android device as part of our developer device seeding program. You are receiving this message because you&#8217;re <a href="http://blog.donnfelker.com/2010/03/04/im-a-considered-a-top-android-dev-cool/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>This last Tuesday I received an email from the Android Market Seeding Program letting me know the following: </p>
<blockquote><p>Due to your contribution to the success of Android Market, we would like to present you with a brand new Android device as part of our developer device seeding program. You are receiving this message because you&#8217;re one of the top developers in Android Market with one or more of your applications having a 3.5 star or higher rating and more than 5,000 unique downloads.</p>
</blockquote>
<p>Very Cool. I wasn’t sure what device I’d get, but further down the email it was mentioned: </p>
<blockquote><p>You will receive either a Verizon Droid by Motorola or a Nexus One. Developers with mailing addresses in the US will receive either a Droid or Nexus one, based on random distribution.</p>
</blockquote>
<p>I’m hoping for a Nexus One only because I’m a T-Mobile customer and I would love to actually USE The phone as well as develop for it. </p>
<p>Why is Google doing this? Plain and simple: Most of us developers who received this have been developing for close to a year or more. That means almost all of us are running on old hardware – eg: <a href="http://www.t-mobileg1.com/" target="_blank">G1</a>’s. The new phones have more memory, better displays, multi-touch and most of all … the updated 2.x operating system. The G1 does not have those features. Google is trying to stimulate the growth of the 2.0 market by providing the top devs with new hardware to develop on. Genius.&#160; This <a href="http://techcrunch.com/2010/03/02/google-handing-out-free-nexus-ones-and-droids-to-top-android-devs/" target="_blank">theory is also shared by the guys at TechCrunch</a>.</p>
<p>Whatever the reason, I’m anxiously awaiting my 2.0 device. I cant wait to develop for it. </p>
<p>Now… if I could only get Microsoft to send me a phone … hmmmmm <img src='http://blog.donnfelker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/03/04/im-a-considered-a-top-android-dev-cool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Editable Grid / List Binding in MVC2</title>
		<link>http://blog.donnfelker.com/2010/02/27/editable-grid-list-binding-in-mvc2/</link>
		<comments>http://blog.donnfelker.com/2010/02/27/editable-grid-list-binding-in-mvc2/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 14:45:26 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC2]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/2010/02/27/editable-grid-list-binding-in-mvc2/</guid>
		<description><![CDATA[Steve Sanderson has a great post on how to perform list binding with MVC2 and custom HTML Prefix Scoping. However, it did not demo the out of box functionality that MVC2 provides, so I’m going to do that here. Please note, I’m using MVC2 RC2 in this example. At the end if this post you <a href="http://blog.donnfelker.com/2010/02/27/editable-grid-list-binding-in-mvc2/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Steve Sanderson has a <a href="http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/" target="_blank">great post</a> on how to perform list binding with MVC2 and custom HTML Prefix Scoping. However, it did not demo the out of box functionality that MVC2 provides, so I’m going to do that here. <em>Please note, I’m using MVC2 RC2 in this example. </em>At the end if this post you will be able to download the solution and run/debut it on your machine. </p>
<h3>The App</h3>
<p>I’m going to be using Steves sample app. When you first first fire it up you will be presented with a link to go to Donn’s list binding demo. This demo emulates using the built in features of MVC2 to great an editable grid or list. It will look like this: </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image1.png" width="644" height="262" /> </p>
<p>After clicking on that link you will be presented with a grid / list that is editable. I’m going to use the EditorFor() expression based input builder and some custom editor for templates to layout the grid. In the end, the grid will look like this (yes, not pretty, but it demonstrates what can be done with some of the editor templates. </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image2.png" width="615" height="585" /> </p>
<p>This is a order list that is set up in the controller manually. The Controller invokes the <em>index</em> action with a customer view model. The customer object has a list of orders, and each order has a list of line items. The objects look like this: </p>
<h3>Customer </h3>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image3.png" width="388" height="124" /> </p>
<h3>&#160;</h3>
<h3>Order</h3>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image4.png" width="410" height="104" /> </p>
</p>
</p>
<h3>&#160;</h3>
<h3>LineItem</h3>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image5.png" width="317" height="121" /> </p>
<h2>&#160;</h2>
<h2>Solution Layout</h2>
<p>The solution is lain out in a way that we can render the Index.aspx, which will render an&#160; editor for the order. The OrderRow.ascx file is the file we use to display the editor. We do that in the Index.aspx page like so: </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image6.png" width="628" height="363" /> </p>
<p>These editor templates are stored in your controllers view folder, under a folder called “EditorTemplates” as shown below:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image7.png" width="453" height="171" />&#160; </p>
</p>
<p>&#160;</p>
<p>The OrderRow.ascx Editor will handle how each editor is formatted for editing:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image8.png" width="624" height="181" /> </p>
<p>We will be using another editor template, “LineItemRow” to format how each line item should be edited. We are using one editor to create another editor, cool! </p>
<p>Here’s the LineItemRow.ascx (which is called from above via the “LineItemRow” parameter in the EditorFor expression based call: </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image9.png" width="638" height="83" /> </p>
<p>&#160;</p>
<p>
<h3>Incremental Sequencing</h3>
<p>The reason the list binding works is because we’re using <em>incremental sequencing</em> while building our editor. We’re using for loops. This allows MVC to know where it’s at during the creation of the form. What does this mean in plain English? MVC will generate incremental name and id’s in the HTML, which, when posting back, the DefaultModelBinder will be able to bind back into the complex object type. </p>
<p>Lets delve into this a bit further. This screen is generated with incremental id’s, and the id’s are shown below in the screen shot for ease of understanding:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image10.png" width="615" height="569" /> </p>
<p>The raw HTML looks like this (click to enlarge): </p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/02/image11.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image_thumb.png" width="644" height="146" /></a> </p>
<p>Using the incremental sequencing and editor templates allows us to change the values and post them back to the form. </p>
<h3>Example</h3>
<p>Lets change the name of “Sneakers” to “Shoes”. Then we’ll post the form. Here’s what we see in the post (via the debugger): </p>
<p><a href="http://blog.donnfelker.com/wp-content/uploads/2010/02/image12.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.donnfelker.com/wp-content/uploads/2010/02/image_thumb1.png" width="569" height="215" /></a> </p>
<h3>Conclusion</h3>
</p>
</p>
<p>Now you can edit the list, post the new updated results and persist them. Fairly simple.</p>
<p>&#160;</p>
<h3><a href="http://blog.donnfelker.com/wp-content/uploads/2010/02/ListEditorDemo.zip" target="_blank">Download the Sample Project (VS2010)</a> </h3>
<p>If you’re using VS2008, you can copy the files into a VS2008 MVC2 RC2 Project (minus the project) and it should work. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/02/27/editable-grid-list-binding-in-mvc2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASPNET MVC2: TempData Now Persists</title>
		<link>http://blog.donnfelker.com/2010/02/26/aspnet-mvc2-tempdata-now-persists/</link>
		<comments>http://blog.donnfelker.com/2010/02/26/aspnet-mvc2-tempdata-now-persists/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 20:20:56 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC2]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/2010/02/26/aspnet-mvc2-tempdata-now-persists/</guid>
		<description><![CDATA[In MVC1, TempData did not persist:
The value of TempData persists only from one request to the next. (source)
This has changed in MVC2. The TempData dictionary will not persist data until the key is read from the dictionary.
…We’ve changed the implementation in MVC 2 slightly as a result: the value will be removed from TempData after <a href="http://blog.donnfelker.com/2010/02/26/aspnet-mvc2-tempdata-now-persists/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>In MVC1, <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controllerbase.tempdata.aspx">TempData</a> did not persist:</p>
<blockquote><p>The value of TempData persists only from one request to the next. (<a href="http://msdn.microsoft.com/en-us/library/dd394711.aspx" target="_blank">source</a>)</p></blockquote>
<p>This has changed in MVC2. The TempData dictionary will not persist data until the key is read from the dictionary.</p>
<blockquote><p>…We’ve changed the implementation in MVC 2 slightly as a result: the value will be removed from TempData after the request in which it is read, so it will continue to exist in your TempData dictionary until you display it in some page. This allows a multi-redirect scenario (such as Windows Live ID login) to use TempData and have it still be hanging around until you&#8217;re ready for it. (<a href="http://forums.asp.net/p/1528070/3694325.aspx" target="_blank">source</a>)</p></blockquote>
<p>This is very important to note because if you use <a href="http://mvccontrib.github.com/MvcContrib/" target="_blank">MVCContrib’s</a> <a href="http://github.com/mvccontrib/MvcContrib/blob/master/src/MVCContrib/Filters/ModelStateToTempDataAttribute.cs" target="_blank">ModelStateToTempData</a> attribute the values in the modelstate will be persisted across requests as it will be present in the TempData across requests. If you’re using button names as decision criteria in your Http Post  then you might notice that your ModelState is traversing into other actions and showing invalid validation on pages where the model is not of the given type of the model state info that is being presented.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/02/26/aspnet-mvc2-tempdata-now-persists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC TempData Extension Methods</title>
		<link>http://blog.donnfelker.com/2010/02/25/asp-net-mvc-tempdata-extension-methods/</link>
		<comments>http://blog.donnfelker.com/2010/02/25/asp-net-mvc-tempdata-extension-methods/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 19:16:44 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/?p=362</guid>
		<description><![CDATA[This is an sister class to some Session classes I wrote awhile back (which I never posted). I  originally wrote these extension methods for the code camp eval system for Twin Cities Code Camp last year.  But I needed it today at my client so I figured I’d post it here for future <a href="http://blog.donnfelker.com/2010/02/25/asp-net-mvc-tempdata-extension-methods/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>This is an sister class to some Session classes I wrote awhile back (which I never posted). I  originally wrote these extension methods for the code camp eval system for <a href="http://www.twincitiescodecamp.com/">Twin Cities Code Camp</a> last year.  But I needed it today at my client so I figured I’d post it here for future  reference … and so you could use it.</p>
<pre class="brush: csharp;">
public static class TempDataExtensions
{
	public static void Put&lt;T&gt;(this TempDataDictionary tempData, T value) where T : class
	{
		tempData[typeof(T).FullName] = value;
	}

	public static void Put&lt;T&gt;(this TempDataDictionary tempData, string key, T value) where T : class
	{
		tempData[typeof(T).FullName + key] = value;
	}

	public static T Get&lt;T&gt;(this TempDataDictionary tempData) where T : class
	{
		object o;
		tempData.TryGetValue(typeof(T).FullName, out o);
		return o == null ? null : (T)o;
	}

	public static T Get&lt;T&gt;(this TempDataDictionary tempData, string key) where T : class
	{
		object o;
		tempData.TryGetValue(typeof(T).FullName + key, out o);
		return o == null ? null : (T)o;
	}
}</pre>
<p>The code above allows you to put values into <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.tempdatadictionary.aspx">TempData</a> in a strongly typed fashion. You can then get the values back out (safely) without worrying about an exception being thrown (temp data will throw if the key is not found).</p>
<p>Usage:</p>
<pre class="brush: csharp;">var customer = new Customer();

TempData.Put(customer); // Strongly typed without key

TempData.Put(&quot;key1&quot;, customer); // Strongly typed with extra key

var tempDataCustomer = TempData.Get&lt;Customer&gt;(); // Get customer without key

var tempDataCustomerWithKey = TempData.Get&lt;Customer&gt;(&quot;key1&quot;); // Get customer with key</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/02/25/asp-net-mvc-tempdata-extension-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My CODE Magazine Article Is Live</title>
		<link>http://blog.donnfelker.com/2010/02/25/my-code-magazine-article-is-live/</link>
		<comments>http://blog.donnfelker.com/2010/02/25/my-code-magazine-article-is-live/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 13:58:12 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[spark]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/?p=368</guid>
		<description><![CDATA[My first article with CODE Magazine is live. You can read it here. I cover ASP.NET MVC with the Spark View Engine. I cover a wide range of things and go in depth with examples with topics that include:

Inline Code
Element Constructs
Partials
Layouts
and more &#8230;

I hope you enjoy it! I enjoyed writing it.
A big thanks goes out <a href="http://blog.donnfelker.com/2010/02/25/my-code-magazine-article-is-live/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>My first article with CODE Magazine is live. <a href="http://www.code-magazine.com/Article.aspx?quickid=1003051">You can read it here.</a> I cover ASP.NET MVC with the <a href="http://www.sparkviewengine.com">Spark View Engine</a>. I cover a wide range of things and go in depth with examples with topics that include:</p>
<ul>
<li>Inline Code</li>
<li>Element Constructs</li>
<li>Partials</li>
<li>Layouts</li>
<li>and more &#8230;</li>
</ul>
<p>I hope you enjoy it! I enjoyed writing it.</p>
<p>A big thanks goes out to <a href="http://geekswithblogs.net/cwilliams/Default.aspx">Chris G. Williams </a>(<a href="http://www.twitter.com/chrisgwilliams">twitter</a>)for doing a stellar job on the tech editing.</p>
<h2><a href="http://www.code-magazine.com/Article.aspx?quickid=1003051">Read it Here</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/02/25/my-code-magazine-article-is-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spaghetti Code Podcast: Android Development</title>
		<link>http://blog.donnfelker.com/2010/02/23/spaghetti-code-podcast-android-development/</link>
		<comments>http://blog.donnfelker.com/2010/02/23/spaghetti-code-podcast-android-development/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 01:00:32 +0000</pubDate>
		<dc:creator>Donn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.donnfelker.com/?p=359</guid>
		<description><![CDATA[I was recently welcomed onto the set of another Spaghetti Code Podcast with Jeff Brand a few weeks back. Jeff and I discussed Android development, mobile development and what I think Microsoft needs to do to succeed in the world the mobile platform.
Note: Part of the conversation seems to insinuate that Flash is the be-all-end-all <a href="http://blog.donnfelker.com/2010/02/23/spaghetti-code-podcast-android-development/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I was recently welcomed onto the set of another <a href="http://www.slickthought.net">Spaghetti Code Podcast</a> with Jeff Brand a few weeks back. Jeff and I discussed <a href="http://developer.android.com">Android</a> development, mobile development and what I think Microsoft needs to do to succeed in the world the mobile platform.</p>
<p><em>Note: Part of the conversation seems to insinuate that Flash is the be-all-end-all platform for development. This is not my stance, however, I do feel that some sort of cross platform rich client development standard is going to have a major impact and possible market share once it is introduced across mobile platforms. If that becomes flash/air, so be it. Just wanted to clear that up. <img src='http://blog.donnfelker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </em></p>
<h2><a href="http://www.slickthought.net/post/2010/02/22/Spaghetti-Code-Talks-Android-with-Donn-Felker.aspx">Download it here</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://blog.donnfelker.com/2010/02/23/spaghetti-code-podcast-android-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
