<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5898028992635002784</id><updated>2011-09-28T13:22:11.932-07:00</updated><title type='text'>Sporadic Thoughts of a Software Developer</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://g-m-a-c.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://g-m-a-c.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Geoff McElhanon</name><uri>http://www.blogger.com/profile/07260343209030527699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp2.blogger.com/_QBVjqbHFN9Y/SAa_hKqqtZI/AAAAAAAAAhk/zxZZgHffRzw/S220/Avatar.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5898028992635002784.post-6461737994523709020</id><published>2010-12-30T12:36:00.001-08:00</published><updated>2011-01-13T08:42:14.821-08:00</updated><title type='text'>Reinitializing your Powershell environment without closing and reopening</title><content type='html'>&lt;p&gt;I’ve been running our builds with &lt;a href="https://github.com/JamesKovacs/psake"&gt;psake&lt;/a&gt;, and have found that I get errors if I try to run a build script twice in the same Powershell session.&amp;#160; I looked around a bit about how to reset your Powershell environment without closing and reopening a Powershell console window, but couldn’t find anything.&amp;#160; &lt;/p&gt;  &lt;p&gt;Here’s what I came up with that works for me.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;And now, the short version:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;rv * -ea SilentlyContinue; rmo *; $error.Clear(); cls&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5898028992635002784-6461737994523709020?l=g-m-a-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://g-m-a-c.blogspot.com/feeds/6461737994523709020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5898028992635002784&amp;postID=6461737994523709020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/6461737994523709020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/6461737994523709020'/><link rel='alternate' type='text/html' href='http://g-m-a-c.blogspot.com/2010/12/reinitializing-your-powershell.html' title='Reinitializing your Powershell environment without closing and reopening'/><author><name>Geoff McElhanon</name><uri>http://www.blogger.com/profile/07260343209030527699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp2.blogger.com/_QBVjqbHFN9Y/SAa_hKqqtZI/AAAAAAAAAhk/zxZZgHffRzw/S220/Avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5898028992635002784.post-2474972334921194572</id><published>2010-12-30T12:23:00.001-08:00</published><updated>2010-12-30T12:26:04.562-08:00</updated><title type='text'>Setting dynamic connection string for dtexec.exe in Powershell</title><content type='html'>&lt;p&gt;This one had me banging my head on the wall and hitting Google hard until I just took a step back and tried to get inside of Powershell’s head.&lt;/p&gt;  &lt;p&gt;Basically I have a Powershell-based build script that (among other things) needs to execute an SSIS package that initializes a database from an Excel spreadsheet, and at the end of the build process deploys a web application to IIS using the Powershell WebAdministration module.&amp;#160; &lt;/p&gt;  &lt;p&gt;But here’s the catch: the Excel data support in SSIS only works in 32-bit mode and the WebAdministration module only works in 64-bit mode.&amp;#160; So what I need to do is launch the 32-bit version of the dtexec.exe utility from my 64-bit Powershell script.&amp;#160; Seems easy enough, right?&amp;#160; Nope.&lt;/p&gt;  &lt;p&gt;After struggling for a while in Powershell, I switched to the good old Windows Command Prompt and managed to get it working fairly quickly using the following syntax:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;&amp;quot;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\DTExec.exe&amp;quot;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /File &amp;quot;C:\Path\To\My\Package\Import Types.dtsx&amp;quot;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /Conn Connection1;&amp;quot;Provider=SQLNCLI10;Server=MYSERVER;Database=DB_ONE;Uid=USERNAME;Pwd=PASSWORD;&amp;quot;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /Conn Connection2;&amp;quot;Provider=SQLNCLI10;Server=MYSERVER;Database=DB_TWO;Uid=USERNAME;Pwd=PASSWORD;&amp;quot;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /Set \package.variables[User::ExcelFilePath].Value;&amp;quot;C:\Path\To\My\Data\Import Types.Data.xls&amp;quot;&lt;/font&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;If you just try to slap a “&amp;amp;” on the front and execute it in Powershell, it doesn’t work.&amp;#160; I tried many variations until I arrived at this particular translation:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;&amp;amp; &amp;quot;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\DTExec.exe&amp;quot;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /File &amp;quot;C:\Path\To\My\Package\Import Types.dtsx&amp;quot;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /Conn &lt;span style="background-color: yellow"&gt;&amp;quot;&lt;/span&gt;Connection1;&lt;span style="background-color: yellow"&gt;`&amp;quot;&lt;/span&gt;Provider=SQLNCLI10;Server=MYSERVER;Database=DB_ONE;Uid=USERNAME;Pwd=PASSWORD;&lt;span style="background-color: yellow"&gt;`&amp;quot;&lt;/span&gt;&amp;quot;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /Conn &lt;span style="background-color: yellow"&gt;&amp;quot;&lt;/span&gt;Connection2;&lt;span style="background-color: yellow"&gt;`&amp;quot;&lt;/span&gt;Provider=SQLNCLI10;Server=MYSERVER;Database=DB_TWO;Uid=USERNAME;Pwd=PASSWORD;&lt;span style="background-color: yellow"&gt;`&amp;quot;&lt;/span&gt;&amp;quot;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /Set &lt;span style="background-color: yellow"&gt;&amp;quot;&lt;/span&gt;\package.variables[User::ExcelFilePath].Value;C:\Path\To\My\Data\Import Types.Data.xls&amp;quot;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I’ve tried to make complete sense of why that particular formatting works, but I can’t.&amp;#160; Here’s a couple of observations about the Powershell version:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The argument &lt;em&gt;values&lt;/em&gt;&amp;#160; need to be wrapped in quotes in their entirety. &lt;/li&gt;    &lt;li&gt;The quotes found in the Command Prompt version need to be escaped in Powershell in order for DTExec to receive them correctly. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;But that second observation is only almost true.&amp;#160; The /Set argument &lt;strong&gt;only&lt;/strong&gt; works if you drop the embedded quotes altogether.&amp;#160; When I tried retaining them from the Command Prompt version and escaping them for inclusion in the Powershell, I got an error.&amp;#160; Dropping the quotes altogether worked, despite the embedded space in the file name.&amp;#160; At this point, however, I’m not arguing!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5898028992635002784-2474972334921194572?l=g-m-a-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://g-m-a-c.blogspot.com/feeds/2474972334921194572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5898028992635002784&amp;postID=2474972334921194572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/2474972334921194572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/2474972334921194572'/><link rel='alternate' type='text/html' href='http://g-m-a-c.blogspot.com/2010/12/setting-dynamic-connection-string-for.html' title='Setting dynamic connection string for dtexec.exe in Powershell'/><author><name>Geoff McElhanon</name><uri>http://www.blogger.com/profile/07260343209030527699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp2.blogger.com/_QBVjqbHFN9Y/SAa_hKqqtZI/AAAAAAAAAhk/zxZZgHffRzw/S220/Avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5898028992635002784.post-9168022417302120567</id><published>2009-08-29T16:02:00.001-07:00</published><updated>2011-05-05T21:27:47.180-07:00</updated><title type='text'>Reducing the Friction of the Resharper Test Runner</title><content type='html'>&lt;p&gt;I've seen many a demonstration where the presenter is using a lightweight test runner like TestDriven.net which allows for the execution of units tests without a lot of GUI fanfare.&amp;#160; A few months ago I was having trouble with the Resharper test runner in Visual Studio (for some reason it stopped building my assembly before executing the tests) and so I wrote a macro that allows you to run tests from the context of the current cursor location.&amp;#160; I’ve mapped this to my F12 key for quick execution.&lt;/p&gt;  &lt;p&gt;Here is the Visual Studio macro that I wrote.&amp;#160; It uses Resharper's unit test context run feature.&amp;#160; Simply position the cursor inside a namespace, class, or test, and when you invoke this macro it will build the assembly in context, and then proceed to run all the tests found in the current cursor context.&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;WithEvents&lt;/span&gt; testLaunchBuildEvents &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; BuildEvents&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; OverallBuildSuccess &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; PayAttention &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; BuildAndTestCodeContext()&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (testLaunchBuildEvents &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            testLaunchBuildEvents = BuildEvents&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        OverallBuildSuccess = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        PayAttention = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        DTE.ExecuteCommand(&amp;quot;&lt;span style="color: #8b0000"&gt;Build.BuildSelection&lt;/span&gt;&amp;quot;)&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; SolutionBuildDoneForUnitTestContextRun(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; Scope &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EnvDTE.vsBuildScope, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; Action &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EnvDTE.vsBuildAction) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; testLaunchBuildEvents.OnBuildDone&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; PayAttention &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            &lt;span style="color: #0000ff"&gt;Exit&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        PayAttention = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; OverallBuildSuccess &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            DTE.ExecuteCommand(&amp;quot;&lt;span style="color: #8b0000"&gt;ReSharper.ReSharper_UnitTest_ContextRun&lt;/span&gt;&amp;quot;)&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            Beep()&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; SingleProjectBuildDoneForUnitTestContextRun( _&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; Project &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, _&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; ProjectConfig &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, _&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; Platform &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; SolutionConfig &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, _&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;            &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; Success &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;Handles&lt;/span&gt; testLaunchBuildEvents.OnBuildProjConfigDone&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;        OverallBuildSuccess = OverallBuildSuccess &lt;span style="color: #0000ff"&gt;And&lt;/span&gt; Success&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: monospace; font-size: 11px"&gt;&lt;/pre&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5898028992635002784-9168022417302120567?l=g-m-a-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://g-m-a-c.blogspot.com/feeds/9168022417302120567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5898028992635002784&amp;postID=9168022417302120567' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/9168022417302120567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/9168022417302120567'/><link rel='alternate' type='text/html' href='http://g-m-a-c.blogspot.com/2009/08/reducing-friction-of-resharper-test.html' title='Reducing the Friction of the Resharper Test Runner'/><author><name>Geoff McElhanon</name><uri>http://www.blogger.com/profile/07260343209030527699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp2.blogger.com/_QBVjqbHFN9Y/SAa_hKqqtZI/AAAAAAAAAhk/zxZZgHffRzw/S220/Avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5898028992635002784.post-1746513296460710672</id><published>2008-09-09T21:17:00.001-07:00</published><updated>2008-11-02T11:23:32.366-08:00</updated><title type='text'>Implementing a Breadth-First Search with LINQ</title><content type='html'>&lt;p&gt;I was working on some code today that will manages the order of execution of some ETL jobs based on some known dependency information.&amp;#160; I've gathered the dependency information into a directed graph that I created using the &lt;a href="http://www.codeplex.com/quickgraph"&gt;QuickGraph&lt;/a&gt; library.&amp;#160; In order to prevent jobs from executing before their dependencies, I need to process the nodes (jobs) of the graph in a breadth-first manner.&amp;#160; For my unit test fixtures I have created the following directed graph:&lt;a href="http://lh5.ggpht.com/BKAlanna/SMdKcuF_d4I/AAAAAAAAAh8/7dzmhYZQcjM/s1600-h/image%5B9%5D.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="142" alt="image" src="http://lh3.ggpht.com/BKAlanna/SMdKc_LAOyI/AAAAAAAAAiA/BZ5fp8ed8M8/image_thumb%5B5%5D.png?imgmax=800" width="324" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When I tried using the built-in breadth first search implementation, it visited the nodes in the following order 1, 3, 2, 5, and 4.&amp;#160; The problem is that it assumes a single root and does not look at the fact that 5 depends on 4, which hasn't run yet.&amp;#160; As I was digging around a bit with the .NET Reflector as to whether I should try implementing my own breadth-first search algorithm, I began thinking that there would probably be an easier solution possible with LINQ.&amp;#160; The highest number of vertices that I'm going to be dealing with at once is about 100, so performance really isn't much of a concern.&lt;/p&gt;  &lt;p&gt;Note: I should mention that the vertices of the graph represent my jobs, which I originally was referring to as &amp;quot;Project Items&amp;quot;.&amp;#160; In the code and comments below, these are all synonymous.&amp;#160; Eric Evans would disappointed in me for my lack of a &lt;em&gt;ubiquitous language&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;I started by initializing a Dictionary to track whether or not a particular job has been executed yet (starting with &amp;quot;false&amp;quot;):&lt;/p&gt;  &lt;pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 750px; padding-top: 5px; border-bottom: #cecece 1px solid; background-color: #fbfbfb"&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;&lt;span style="color: #008000"&gt;// Initialize dictionary to track execution of all vertices&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;&lt;font color="#008080"&gt;Dictionary&lt;/font&gt;&amp;lt;&lt;font color="#408080"&gt;ProjectItem&lt;/font&gt;, &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;&amp;gt; executedByProjectItem = graph.Vertices.ToDictionary(v =&amp;gt; v, e =&amp;gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Then I loop until they've all been executed:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 750px; padding-top: 5px; border-bottom: #cecece 1px solid; background-color: #fbfbfb"&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;&lt;font color="#008000"&gt;// Keep looping while some jobs have not been executed&lt;/font&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;&lt;span style="color: #0000ff"&gt;while&lt;/span&gt; (executedByProjectItem.Values.Any(e =&amp;gt; !e))&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;{&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;	...&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #fbfbfb"&gt;}&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Inside the loop, the first thing I want to do is get a list of all the vertices (ProjectItems) that can currently be executed.&amp;#160; To get this list:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;I start with the graph's vertices and ... &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;I perform a join to the edges... &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ...where the vertex name matches the edge's target vertex's name.&amp;#160; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;The &lt;strong&gt;GroupJoin&lt;/strong&gt; method provides a collection of edges for each vertex in my graph.&amp;#160; &lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;From that join, I create a new anonymous type that contains a reference to the vertex, &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ...and then a count of the related edges for which the source job has yet to execute.&amp;#160; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;With that calculation in hand, I filter the list down to just those vertices that have no unexecuted dependencies &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ...and have not already been executed themselves (root vertices would otherwise continue to be executed since they will always have an &lt;strong&gt;UnexecutedDependencyCount&lt;/strong&gt; of&amp;#160; 0).&amp;#160; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;In the final step, I use the &lt;strong&gt;Select&lt;/strong&gt; projection method to create a return set of &lt;strong&gt;IEnumerable&lt;/strong&gt;&amp;lt;&lt;strong&gt;ProjectItem&lt;/strong&gt;&amp;gt; instead of the anonymous type, since that's what I'm really interested in. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/BKAlanna/SMdKdKy2f-I/AAAAAAAAAiE/pmnQg_3KDVk/s1600-h/image%5B25%5D.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="image" src="http://lh4.ggpht.com/BKAlanna/SMdKdSszgZI/AAAAAAAAAiI/ofsna4OTYBs/image_thumb%5B15%5D.png?imgmax=800" width="820" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The final step of the loop is to just iterate through all the jobs that can be executed, and uh... execute them.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;When I ran this code, the output looked like this:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem4&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;=== Pass complete ====&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;=== Pass complete ====&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;There is a subtle issue at work here.&amp;#160; Based on my query, I should have only seen 1 and 4 in the first pass.&amp;#160; Job 3 should have been executed on the second pass, once Job 1 had been executed.&amp;#160; However, due to the nature of deferred execution of some operations in LINQ, once Job 1 has been marked as executed, Job 3 just showed up to the party late.&amp;#160; It's obviously not wrong, it was just a little unexpected the first time I saw it.&amp;#160; To get a static list on the first pass, I could add a call to the &lt;strong&gt;ToList()&lt;/strong&gt; at #8 in the code listing above, which would have iterated through the collection immediately.&amp;#160; With the &lt;strong&gt;ToList&lt;/strong&gt; call in place, the code produces the following output:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem4&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;=== Pass complete ====&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;=== Pass complete ====&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;=== Pass complete ====&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;Executing job: projectItem5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;=== Pass complete ====&lt;br /&gt;&lt;/pre&gt;&lt;pre style="font-size: 11px; margin: 0em; width: 100%; font-family: monospace; background-color: #ffffff"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;It's interesting how the deferred execution actually cuts down on the number of times I have to iterate through the jobs to execute them all (from 4 to 2), and because the results will still be correct, I've gone without the &lt;strong&gt;ToList&lt;/strong&gt; in my final copy of the code.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;At the end of the day, I am happy with how that worked out.&amp;#160; In about 30 lines of code with LINQ, I was able to implement a reliable Breadth First iteration of my directed graph with potentially multiple root nodes.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5898028992635002784-1746513296460710672?l=g-m-a-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://g-m-a-c.blogspot.com/feeds/1746513296460710672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5898028992635002784&amp;postID=1746513296460710672' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/1746513296460710672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/1746513296460710672'/><link rel='alternate' type='text/html' href='http://g-m-a-c.blogspot.com/2008/09/implementing-breadth-first-search-with.html' title='Implementing a Breadth-First Search with LINQ'/><author><name>Geoff McElhanon</name><uri>http://www.blogger.com/profile/07260343209030527699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp2.blogger.com/_QBVjqbHFN9Y/SAa_hKqqtZI/AAAAAAAAAhk/zxZZgHffRzw/S220/Avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/BKAlanna/SMdKc_LAOyI/AAAAAAAAAiA/BZ5fp8ed8M8/s72-c/image_thumb%5B5%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5898028992635002784.post-6918923573951017547</id><published>2008-04-21T15:07:00.001-07:00</published><updated>2008-08-30T10:07:59.097-07:00</updated><title type='text'>How SharePoint 2007 Renders Its Content</title><content type='html'>&lt;p&gt;In my previous &lt;a href="http://g-m-a-c.blogspot.com/2008/04/customizing-sharepoint-2007-forms.html"&gt;post&lt;/a&gt;, I showed how to customize a list form without losing all the built-in SharePoint functionality.  At the heart of my approach was harnessing SharePoint's own template rendering mechanism, the details of which I'm going to dive into now.&lt;/p&gt;  &lt;p&gt;If you've ever used any of the template-based controls in ASP.NET (&lt;span style="font-family:Consolas;"&gt;GridView&lt;/span&gt;, &lt;span style="font-family:Consolas;"&gt;Repeater&lt;/span&gt;, &lt;span style="font-family:Consolas;"&gt;DataList&lt;/span&gt;, etc.), then you've already touched on the core concept.  For example, the &lt;span style="font-family:Consolas;"&gt;Repeater &lt;/span&gt;control provides various templates (header, footer, item, alternating item, etc.) that allow you to control what content is rendered at different points during the rendering process.  Typically you'll provide markup for the control on your page like so:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(199, 21, 133);"&gt;asp&lt;/span&gt;:&lt;span style="color: rgb(128, 0, 0);"&gt;Repeater&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"myRepeaterUL"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ul&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;li&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;a&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;href&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;'&amp;lt;%# DataBinder.Eval(Container.DataItem, "URL") %&amp;gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;        &lt;span style="background-color: rgb(255, 255, 0);" &gt;&amp;lt;%&lt;/span&gt;# DataBinder.Eval(Container.DataItem, "Name") &lt;span style="background-color: rgb(255, 255, 0);" &gt;%&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;      &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;a&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;li&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;FooterTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:Monospace;font-size:11px;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ul&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre face="Monospace" size="11px" style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;"&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;FooterTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre face="Monospace" size="11px" style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(199, 21, 133);"&gt;asp&lt;/span&gt;:&lt;span style="color: rgb(128, 0, 0);"&gt;Repeater&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre face="Monospace" size="11px" style="margin: 0em; background-color: rgb(255, 255, 255); width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;Each template you provide in the page markup is loaded by the ASP.NET runtime and exposed through the &lt;span style="font-family:Consolas;"&gt;ITemplate&lt;/span&gt; interface which has a single method with the following signature:&lt;br /&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style="font-family:Consolas;"&gt;void InstantiateIn(Control container)&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;With the templates loaded, all the &lt;span style="font-family:Consolas;"&gt;Repeater&lt;/span&gt; control has to do to instantiate a new row of data is call this method passing in the appropriate container.  New instances of any contained ASP.NET controls will be instantiated and processed through the usual ASP.NET control lifecycle.&lt;/p&gt;&lt;p&gt;Now switching back into the SharePoint world, if you look in the &lt;span style="font-family:Consolas;"&gt;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES&lt;/span&gt; folder, you will see a number of user control files (*.ascx) most of which contain very standard looking user control content.  However, the largest of these files (&lt;em&gt;DefaultTemplates.ascx&lt;/em&gt;) is a bit different and since it is at the heart of SharePoint's template rendering mechanism, it is the one I am focusing on.  If you open up the file you will see that it contains nothing but instances of the &lt;span style="font-family:Consolas;"&gt;&amp;lt;SharePoint:RenderingTemplate&amp;gt;&lt;/span&gt; control.  Each &lt;span style="font-family:Consolas;"&gt;RenderingTemplate &lt;/span&gt;control instance has a unique ID and a single child &lt;span style="font-family:Consolas;"&gt;&amp;lt;Template&amp;gt;&lt;/span&gt; element.  When SharePoint starts up, it parses all files in this folder and makes all the templates it finds easily accessible through the static &lt;span style="font-family:Consolas;"&gt;GetTemplateByName &lt;/span&gt;method of the &lt;span style="font-family:Consolas;"&gt;SPControlTemplateManager&lt;/span&gt; class.  &lt;/p&gt;&lt;p&gt;In my last post, I showed a web part that exposes a &lt;strong&gt;Template ID&lt;/strong&gt; setting that is used as the basis for its rendering.  Instead of overriding one of the web part rendering methods like &lt;span style="font-family:Consolas;"&gt;Render&lt;/span&gt; or &lt;span style="font-family:Consolas;"&gt;RenderControl&lt;/span&gt;, I am overriding the &lt;span style="font-family:Consolas;"&gt;CreateChildControls &lt;/span&gt;method.  I simply create an instance of SharePoint's &lt;span style="font-family:Consolas;"&gt;TemplateContainer&lt;/span&gt; control, provide its template by loading the template specified in the web part's &lt;strong&gt;Template ID&lt;/strong&gt; setting, add the &lt;span style="font-family:Consolas;"&gt;TemplateContainer &lt;/span&gt;instance to my web part's &lt;span style="font-family:Consolas;"&gt;Controls &lt;/span&gt;collection.  ASP.NET does the rest.  Here's the snippet of code I am referring to:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="margin: 0em; background-color: rgb(255, 255, 255); font-family: Monospace; font-size: 11px; width: 100%;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// Initialize template container with our custom template&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="margin: 0em; background-color: rgb(255, 255, 255); font-family: Monospace; font-size: 11px; width: 100%;"&gt;templateContainer = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; TemplateContainer();&lt;br /&gt;&lt;/pre&gt;&lt;pre style="margin: 0em; background-color: rgb(255, 255, 255); font-family: Monospace; font-size: 11px; width: 100%;"&gt;templateContainer.Template = SPControlTemplateManager.GetTemplateByName(RenderingTemplateId);&lt;br /&gt;&lt;/pre&gt;&lt;pre style="margin: 0em; background-color: rgb(255, 255, 255); font-family: Monospace; font-size: 11px; width: 100%;"&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;pre style="margin: 0em; background-color: rgb(255, 255, 255); font-family: Monospace; font-size: 11px; width: 100%;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// Add the container to the webpart control hierarchy&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="margin: 0em; background-color: rgb(255, 255, 255); font-family: Monospace; font-size: 11px; width: 100%;"&gt;Controls.Add(templateContainer);&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div&gt;The custom template that I added to the &lt;span style="font-family:Consolas;"&gt;CONTROLTEMPLATES&lt;/span&gt; folder to drive the rendering of my web part was derived from the &lt;span style="font-family:Consolas;"&gt;ListForm &lt;/span&gt;template in &lt;em&gt;DefaultTemplates.ascx&lt;/em&gt; which looks like this:&lt;/div&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;br /&gt;&lt;div   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ListForm"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;amp;gt&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SPAN&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;='part1'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:InformationBar&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;wssuc:ToolBar&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;CssClass&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ms-formtoolbar"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="toolBarTbltop"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;RightButtonSeparator&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="&amp;amp;nbsp;"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template_RightButtons&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:NextPageButton&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:SaveButton&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:GoBackButton&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template_RightButtons&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;wssuc:ToolBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:FormToolBar&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TABLE&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ms-formtable"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;style&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="margin-top: 8px;"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;border&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cellpadding&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cellspacing&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="100%"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:ChangeContentType&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:FolderFormFields&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:ListFieldIterator&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:ApprovalStatus&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:FormComponent&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;TemplateName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="AttachmentRows"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TABLE&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;table&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cellpadding&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cellspacing&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="100%"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ms-formline"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;IMG&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;SRC&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="/_layouts/images/blank.gif"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;1&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;height&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;1&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;alt&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=""&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;table&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TABLE&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cellpadding&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;cellspacing&lt;/span&gt;=&lt;span style="color: rgb(255, 0, 0);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="100%"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;style&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="padding-top: 7px"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="100%"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:ItemHiddenVersion&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:ParentInformationField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:InitContentType&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;wssuc:ToolBar&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;CssClass&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ms-formtoolbar"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="toolBarTbl"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;RightButtonSeparator&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="&amp;amp;nbsp;"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template_Buttons&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:CreatedModifiedInfo&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template_Buttons&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template_RightButtons&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:SaveButton&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;                         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:GoBackButton&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt;                     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template_RightButtons&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  33:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;wssuc:ToolBar&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  34:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;tr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TABLE&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  35:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SPAN&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  36:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:AttachmentUpload&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  37:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  38:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;There's a lot in that template that I could discuss, but the part I want to focus on is the &lt;span style="font-family:Consolas;"&gt;ListFieldIterator&lt;/span&gt; on line 16 as this is where all the field rendering occurs.  &lt;/p&gt;&lt;p&gt;Before we dive in, you first need to understand that the context under which the page is running in SharePoint is key in defining the behavior of the &lt;span style="font-family:Consolas;"&gt;ListFieldIterator&lt;/span&gt;.  When you reassign a particular page as the "Edit" form for a list, you'll notice that the URL in the browser carries this context to the page when it loads.  For example, in my "Edit Test Center" page example from my first post, the URL that SharePoint uses to launch the edit page with context looks like this:&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Consolas;"&gt;http://vm-mossdev/sites/intranet/Test%20Security/Pages/TestCenterEdit.aspx?ID=1&amp;amp;List=9a2e36fb-2f44-4355-a2c6-103a6376ac8b&amp;amp;Source=http%3a%2f%2fvm-mossdev%2fsites%2fintranet%2fTest+Security%2fLists%2fTest+Centers%2fAllItems.aspx&lt;/span&gt;&lt;/p&gt;&lt;p&gt;SharePoint uses the &lt;em&gt;ID&lt;/em&gt; and &lt;em&gt;List&lt;/em&gt; parameters to establish the context for the page, and exposes this via the &lt;span style="font-family:Consolas;"&gt;SPContext&lt;/span&gt; class.  This class has a plethora of information about the current SharePoint context including the list (&lt;span style="font-family:Consolas;"&gt;SPList&lt;/span&gt;), the current item (&lt;span style="font-family:Consolas;"&gt;SPItem&lt;/span&gt;), and the most importantly for our purposes now, the field definitions (&lt;span style="font-family:Consolas;"&gt;SPField&lt;/span&gt;) for the underlying list.&lt;/p&gt;&lt;p&gt;Using this context, the &lt;span style="font-family:Consolas;"&gt;ListFieldIterator&lt;/span&gt; iterates through the fields, creating new &lt;span style="font-family:Consolas;"&gt;TemplateContainer&lt;/span&gt; controls and adding them to its Controls collection.  Importantly, it assigns the &lt;span style="font-family:Consolas;"&gt;FieldName&lt;/span&gt; and &lt;span style="font-family:Consolas;"&gt;ControlMode&lt;/span&gt; properties.  The &lt;span style="font-family:Consolas;"&gt;FieldName &lt;/span&gt;is used later in the process by SharePoint to determine (based on the corresponding &lt;span style="font-family:Consolas;"&gt;SPField&lt;/span&gt; instance) what kind of control should actually be rendered. The &lt;span style="font-family:Consolas;"&gt;ControlMode&lt;/span&gt; property is used to indicate whether the control is in &lt;em&gt;New&lt;/em&gt;, &lt;em&gt;Edit&lt;/em&gt; or &lt;em&gt;Display&lt;/em&gt; mode, which the &lt;span style="font-family:consolas;"&gt;ListFieldIterator &lt;/span&gt;assigns based on the value of its own &lt;span style="font-family:Consolas;"&gt;ControlMode &lt;/span&gt;property.&lt;/p&gt;&lt;p&gt;Once it has created the &lt;span style="font-family:Consolas;"&gt;TemplateContainer &lt;/span&gt;control, the template container needs a… you guessed it…  template to contain.  Since the &lt;span style="font-family:Consolas;"&gt;ListFieldIterator &lt;/span&gt;class overrides the &lt;span style="font-family:Consolas;"&gt;DefaultTemplateName &lt;/span&gt;property to return “&lt;em&gt;ListFieldIterator&lt;/em&gt;”, this is the template that is loaded for each field.  Looking in the &lt;em&gt;DefaultTemplates.ascx&lt;/em&gt; file, this template looks like this:&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;div   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;br /&gt;&lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ListFieldIterator"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TR&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:CompositeField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TR&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;When this template is evaluated and constructed, the &lt;span style="font-family:Consolas;"&gt;CompositeField&lt;/span&gt; control simply overrides &lt;span style="font-family:Consolas;"&gt;DefaultTemplateName&lt;/span&gt; to first check whether the control mode is &lt;span style="font-family:Consolas;"&gt;SPControlMode.Display &lt;/span&gt;and returns either “&lt;em&gt;DisplayCompositeField&lt;/em&gt;” or “&lt;em&gt;CompositeField&lt;/em&gt;”.  The “&lt;em&gt;CompositeField&lt;/em&gt;” template looks like this:&lt;/p&gt;&lt;div   style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;br /&gt;&lt;div   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;br /&gt;&lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="CompositeField"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TD&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;nowrap&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;valign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="top"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="190px"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ms-formlabel"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;H3&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ms-standardheader"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:FieldLabel&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;H3&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TD&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;span style="font-family:Georgia,serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TD&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;valign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="top"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ms-formbody"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="400px"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- FieldName="&amp;lt;SharePoint:FieldProperty PropertyName="Title" runat="server"/&amp;gt;"&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;             FieldInternalName="&amp;lt;SharePoint:FieldProperty PropertyName="InternalName" runat="server"/&amp;gt;"&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;             FieldType="SPField&amp;lt;SharePoint:FieldProperty PropertyName="Type" runat="server"/&amp;gt;"&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;          --&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:FormField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:FieldDescription&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:AppendOnlyHistory&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;TD&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="color: rgb(0, 0, 0);"&gt;What you will notice is that it contains markup and SharePoint controls for rendering both the label (&amp;lt;&lt;span style="font-family:Consolas;"&gt;SharePoint:FieldLabel&amp;gt;&lt;/span&gt;) and the UI control that will be rendered to edit the underlying data (&amp;lt;&lt;span style="font-family:Consolas;"&gt;SharePoint:FormField&amp;gt;&lt;/span&gt;).  The &lt;span style="font-family:Consolas;"&gt;CompositeField &lt;/span&gt;inherits from &lt;span style="font-family:Consolas;"&gt;FieldMetadata &lt;/span&gt;which exposes a &lt;span style="font-family:Consolas;"&gt;Field &lt;/span&gt;property which returns a reference to the SPField instance that is the basis for the current control’s rendering.  However, there is nothing immediately obvious in the current context about how this control was created that defines this.  If you remember back when the &lt;span style="font-family:Consolas;"&gt;ListFieldIterator &lt;/span&gt;was iterating through the &lt;span style="font-family:Consolas;"&gt;Fields &lt;/span&gt;collection, it set the &lt;span style="font-family:Consolas;"&gt;FieldName &lt;/span&gt;property of each &lt;span style="font-family:Consolas;"&gt;TemplateContainer &lt;/span&gt;controls it was creating.  That &lt;span style="font-family:Consolas;"&gt;TemplateContainer &lt;/span&gt;control is now the proud parent of our bouncing little &lt;span style="font-family:Consolas;"&gt;CompositeField&lt;/span&gt; instance, and the &lt;span style="font-family:Consolas;"&gt;FieldName&lt;/span&gt; property implementation of &lt;span style="font-family:Consolas;"&gt;CompositeField&lt;/span&gt; climbs the control hierarchy to get the field name from the &lt;span style="font-family:Consolas;"&gt;TemplateContainer&lt;/span&gt; which is then used by the &lt;span style="font-family:Consolas;"&gt;Field &lt;/span&gt;property on the &lt;span style="font-family:Consolas;"&gt;CompositeField&lt;/span&gt; control to return the appropriate &lt;span style="font-family:Consolas;"&gt;SPField&lt;/span&gt; object based on the list currently in context.  Is your head spinning yet?&lt;/div&gt;&lt;p&gt;When the &lt;span style="font-family:Consolas;"&gt;FieldLabel&lt;/span&gt; control is created (which also inherits from &lt;span style="font-family:Consolas;"&gt;FieldMetadata&lt;/span&gt;), it obtains the current &lt;span style="font-family:Consolas;"&gt;SPField &lt;/span&gt;through the inherited &lt;span style="font-family:Consolas;"&gt;Field &lt;/span&gt;property (which again in this case climbs the control hierarchy to the &lt;span style="font-family:Consolas;"&gt;CompositeField&lt;/span&gt;, then to the &lt;span style="font-family:Consolas;"&gt;TemplateContainer &lt;/span&gt;control as described above).  Then depending on the &lt;span style="font-family:Consolas;"&gt;ControlMode&lt;/span&gt; (whether for Display or not) and the field’s &lt;span style="font-family:Consolas;"&gt;Required&lt;/span&gt; property in the list definition, it uses one of three templates:  &lt;em&gt;FieldLabelForDisplay&lt;/em&gt;, &lt;em&gt;FieldLabelRequired&lt;/em&gt;, or &lt;em&gt;FieldLabelDefault&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;The most interesting of these three is the &lt;em&gt;FieldLabelRequired&lt;/em&gt; template which includes the markup necessary for rendering the familiar little red asterisk next to the label.  It looks like this:&lt;/p&gt;&lt;pre&gt;&lt;pre   style="margin: 0em; width: 100%; background-color: rgb(255, 255, 255);font-family:monospace;font-size:12px;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(199, 21, 133);"&gt;SharePoint&lt;/span&gt;:&lt;span style="color: rgb(128, 0, 0);"&gt;RenderingTemplate&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"FieldLabelRequired"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; width: 100%; background-color: rgb(255, 255, 255);font-family:monospace;font-size:12px;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; width: 100%; background-color: rgb(255, 255, 255);font-family:monospace;font-size:12px;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;nobr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(199, 21, 133);"&gt;SharePoint&lt;/span&gt;:&lt;span style="color: rgb(128, 0, 0);"&gt;FieldProperty&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;PropertyName&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"Title"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;span&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 255);"&gt;"ms-formvalidation"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt; *&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;span&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;nobr&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; width: 100%; background-color: rgb(255, 255, 255);font-family:monospace;font-size:12px;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style="margin: 0em; width: 100%; background-color: rgb(255, 255, 255);font-family:monospace;font-size:12px;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(199, 21, 133);"&gt;SharePoint&lt;/span&gt;:&lt;span style="color: rgb(128, 0, 0);"&gt;RenderingTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;p&gt;When the &amp;lt;&lt;span style="font-family:Consolas;"&gt;SharePoint:FieldProperty&amp;gt; &lt;/span&gt;control is rendered by ASP.NET, it pulls the "&lt;em&gt;Title&lt;/em&gt;" field value (as defined in the &lt;span style="font-family:Consolas;"&gt;PropertyName &lt;/span&gt;attribute of the markup) from the current &lt;span style="font-family:Consolas;"&gt;SPItem &lt;/span&gt;and renders it.  (NOTE: If you look in the &lt;em&gt;DefaultTemplates.ascx&lt;/em&gt; file you will see that the &lt;span style="font-family:Consolas;"&gt;FieldProperty&lt;/span&gt; control is used quite frequently to render various properties of fields.  You can see an example of this in the HTML comments generated by the &lt;em&gt;CompositeField &lt;/em&gt;template above).&lt;/p&gt;&lt;p&gt;Let’s move back now to the second part of the &lt;em&gt;CompositeField&lt;/em&gt; template that I want to highlight: the &lt;span style="font-family:Consolas;"&gt;&amp;lt;SharePoint:FormField&amp;gt; &lt;/span&gt;control.  In absence of an explicit template or template name, the &lt;span style="font-family:Consolas;"&gt;FormField&lt;/span&gt; control uses its associated &lt;span style="font-family:Consolas;"&gt;Field's&lt;/span&gt; &lt;span style="font-family:Consolas;"&gt;FieldRenderingControl &lt;/span&gt;property to retrieve a template-based &lt;span style="font-family:Consolas;"&gt;BaseFieldControl &lt;/span&gt;instance that is capable of rendering UI elements specifically for viewing or editing data for the current field type.  It then adds this control to its &lt;span style="font-family:Consolas;"&gt;Controls &lt;/span&gt;collection.&lt;/p&gt;&lt;p&gt;For an example, if the current field being rendered is a text field, the &lt;span style="font-family:Consolas;"&gt;Field &lt;/span&gt;property will actually return an instance of an &lt;span style="font-family:Consolas;"&gt;SPFieldText&lt;/span&gt; which inherits from &lt;span style="font-family:Consolas;"&gt;SPField&lt;/span&gt; and overrides the &lt;span style="font-family:Consolas;"&gt;FieldRenderingControl&lt;/span&gt; property to return an instance of the &lt;span style="font-family:Consolas;"&gt;TextField&lt;/span&gt; template-based control.  Since the &lt;span style="font-family:Consolas;"&gt;TextField &lt;/span&gt;control overrides the &lt;span style="font-family:Consolas;"&gt;DefaultTemplateName&lt;/span&gt; property to return "&lt;em&gt;TextField&lt;/em&gt;", the following template is generally used (but not always, as in the case of "Choice" fields):&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;div   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;br /&gt;&lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="TextField"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:TextBox&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="TextField"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;MaxLength&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="255"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;br&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244);font-family:consolas,'Courier New',courier,monospace;font-size:8pt;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Template&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;  &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; line-height: 12pt;font-family:consolas,'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SharePoint:RenderingTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;So finally, when the &lt;span style="font-family:Consolas;"&gt;FormField&lt;/span&gt; control is rendered, its child control (the &lt;span style="font-family:Consolas;"&gt;TextField&lt;/span&gt;) is rendered, which results in the template listed above being processed and at the end of this &lt;strong&gt;very&lt;/strong&gt; long chain of SharePoint infrastructure… out comes a plain old vanilla ASP.NET &lt;span style="font-family:Consolas;"&gt;TextBox&lt;/span&gt; control.  Phew!&lt;/p&gt;&lt;p&gt;Now I realize that this is an awful lot to take in, and this post is largely based on notes that I took for myself as I went and traced through all the logic so that I could understand what was going on under the covers.  The upshot of it is that once you understand the rendering mechanism SharePoint uses, you can begin to customize your forms using custom templates in ways that used to require a complete departure from the out-of-the-box SharePoint functionality.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5898028992635002784-6918923573951017547?l=g-m-a-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://g-m-a-c.blogspot.com/feeds/6918923573951017547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5898028992635002784&amp;postID=6918923573951017547' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/6918923573951017547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/6918923573951017547'/><link rel='alternate' type='text/html' href='http://g-m-a-c.blogspot.com/2008/04/how-sharepoint-2007-renders-its-content.html' title='How SharePoint 2007 Renders Its Content'/><author><name>Geoff McElhanon</name><uri>http://www.blogger.com/profile/07260343209030527699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp2.blogger.com/_QBVjqbHFN9Y/SAa_hKqqtZI/AAAAAAAAAhk/zxZZgHffRzw/S220/Avatar.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5898028992635002784.post-1047787301669345236</id><published>2008-04-16T15:31:00.001-07:00</published><updated>2008-04-18T15:40:55.079-07:00</updated><title type='text'>Customizing SharePoint 2007 Forms Without Losing Attachments (et al.) Functionality</title><content type='html'>&lt;p&gt;I recently had some time on my hands, so I decided to explore different ways of customizing SharePoint forms in an effort to find the &amp;quot;best&amp;quot; way.&amp;#160; It seemed to me that to truly reap the benefits of using SharePoint as a development platform, the key was to reuse as much out-of-box functionality as possible (i.e. attachments, delete logic that is sensitive to the recycle bin's state, optimistic conflict detection on updates, etc).&amp;#160; However, once I started digging into the options for customizing forms, I was left wanting.&amp;#160; &lt;/p&gt;  &lt;p&gt;First, I tried my hand at writing custom web parts and ended up with a lot of tedious coding (compared with the classic ASP.NET designer experience).&amp;#160; While I did wrap up some of the rendering logic into reusable base class methods to maintain the SharePoint look and feel, I was not satisfied with the experience and continued my search.&lt;/p&gt;  &lt;p&gt;This led me to find &lt;a href="http://weblogs.asp.net/jan/"&gt;Jan Tielens'&lt;/a&gt; excellent work on the &lt;a href="http://www.codeplex.com/smartpart"&gt;SmartPart&lt;/a&gt; which is essentially a web part that hosts an ASP.NET user control.&amp;#160; It's great for enabling an ASP.NET designer experience, but doesn't really help accomplish the goal of reusing existing SharePoint functionality (additionally it has the drawback of making it a bit clumsy for users to configure your web parts themselves if that is applicable in your scenario).&lt;/p&gt;  &lt;p&gt;At this point, my history in using code generation for data layers going back into the 90's came to the surface, and I briefly considered implementing code templates that would inspect the SharePoint list definitions and do all the initial gruntwork of setting up a page.&amp;#160; But then again, I'd be in the position of essentially reimplementing or figuring out how to integrate all the out-of-the-box SharePoint goodness described above.&amp;#160; Not the business I wanted to be in.&lt;/p&gt;  &lt;p&gt;Still not satisfied I found some information on &lt;a href="http://kalsing.blogspot.com/2006/11/create-custom-list-form-for-sharepoint.html"&gt;using SharePoint Designer to insert a custom list form&lt;/a&gt;, but I (and obviously a few others) found it to be problematic since it broke the functionality for attachments (or &amp;quot;&lt;em&gt;attachements&lt;/em&gt;&lt;strong&gt;&amp;quot;&lt;/strong&gt; if you ask the Microsoft developer who wrote the JavaScript).&amp;#160; Also, I was well outside of the world I wanted to be in for further customizations (some pretty heinous looking XSLT and JavaScript... yeech).&lt;/p&gt;  &lt;p&gt;And so the little bird looked on...&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/BKAlanna/SAZ-HKqqs-I/AAAAAAAAAeQ/n-aG1x-EQPw/image5.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="206" alt="image" src="http://lh4.ggpht.com/BKAlanna/SAZ-H6qqs_I/AAAAAAAAAeY/na802XxPE5A/image_thumb11%5B1%5D.png" width="199" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I had recently become aware of the existence of all the templates in the the &lt;font face="Consolas"&gt;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES&lt;/font&gt; folder, and I decided that to stand the best chance of reusing SharePoint functionality, I needed to understand how SharePoint renders its own content.&lt;/p&gt;  &lt;p&gt;So I rolled up my sleeves, whipped out my trusty &lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;.NET Reflector&lt;/a&gt; and went to work.&amp;#160; If there is interest, I will post a follow up on the details of my exploration through SharePoint's template rendering logic.&lt;/p&gt;  &lt;p&gt;For the rest of you who just want to customize a form and retain attachments functionality, here's the skinny.&lt;/p&gt;  &lt;h5&gt;Solution&lt;/h5&gt;  &lt;p&gt;I have a list in my site that has some test data on Test Centers which I'll be using for this example.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/BKAlanna/SAZ-IaqqtAI/AAAAAAAAAeg/LHznYV-2CHA/image52.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="99" alt="image" src="http://lh4.ggpht.com/BKAlanna/SAZ-I6qqtBI/AAAAAAAAAeo/Jl3BOFZ8m3Y/image_thumb28.png" width="644" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Below is a screen shot of the out-of-the-box Edit form which I want to customize.&amp;#160; For this example, let's assume that I want to make the Test Center Number and address components read-only, and I don't want either the phone or fax number to be displayed at all.&amp;#160; When I'm done, I want all the existing out-of-the-box SharePoint functionality to be preserved (Attach File, Delete Item, Spelling, optimistic Updates, created/modified by information, etc.).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/BKAlanna/SAZ-JaqqtCI/AAAAAAAAAew/MWxUhsvs4Pc/image25.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="495" alt="image" src="http://lh4.ggpht.com/BKAlanna/SAZ-J6qqtDI/AAAAAAAAAe4/aZghrahk-bc/image_thumb14.png" width="689" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;p&gt;When I put this solution together, I used Jan Tielens' &lt;a href="http://www.codeplex.com/smarttemplates"&gt;Smart Templates&lt;/a&gt; for VS 2008 which made the process of building and deploying the web part an absolute breeze.&amp;#160; It creates a Setup folder that contains an installer (&lt;font face="Consolas"&gt;Setup.exe&lt;/font&gt;) which you'll need to run.&lt;/p&gt;  &lt;p&gt;Once installed and deployed, activate it in the Site Collection Features page:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/BKAlanna/SAZ-LKqqtEI/AAAAAAAAAfA/qADxfScAu8Y/image31.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="216" alt="image" src="http://lh3.ggpht.com/BKAlanna/SAZ-LqqqtFI/AAAAAAAAAfI/EgCcEjnJljQ/image_thumb1.png" width="833" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Before attempting to use the web part, you'll also need to install the &lt;font face="Consolas"&gt;CustomListForms.dll&lt;/font&gt; assembly (which should now be located in your web site's bin folder) into the GAC.&amp;#160; This can be done by dragging the file into the &lt;font face="Consolas"&gt;C:\Windows\assembly&lt;/font&gt; folder in Windows Explorer, or from a command prompt using the following command:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;gacutil.exe /i &amp;quot;&amp;lt;assemblyFilePath&amp;gt;&amp;quot;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Next, add a new web part page to your site (I called mine &amp;quot;TestCenterEdit&amp;quot;) and add an instance of the Custom List Form Web Part, which can be found in the &amp;quot;Custom List Forms&amp;quot; section.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/BKAlanna/SAZ-MKqqtGI/AAAAAAAAAfQ/KQBauzWn4TA/image7.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="144" alt="image" src="http://lh6.ggpht.com/BKAlanna/SAZ-MaqqtHI/AAAAAAAAAfY/Klglqimb12Y/image_thumb3.png" width="642" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you scroll all the way to the bottom in the properties pane on the right side of the page, you'll see the &amp;quot;Custom List Properties&amp;quot; section.&amp;#160; Expanding that shows the following settings (yours will be blank initially):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/BKAlanna/SAZ-MqqqtII/AAAAAAAAAfg/zJyH_e2yuNE/image11.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="338" alt="image" src="http://lh5.ggpht.com/BKAlanna/SAZ-NKqqtJI/AAAAAAAAAfo/4j-zDbSSquI/image_thumb5.png" width="241" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;Template ID&lt;/strong&gt; identifies the ID of the template that SharePoint is going to use to render the web part (I'll show you how to add that template shortly).&amp;#160; The &lt;strong&gt;Field List &lt;/strong&gt;allows you define the fields (as a semicolon delimited list) that you are targeting for inclusion/exclusion on the form based on the selection in &lt;strong&gt;Field List Type&lt;/strong&gt;.&amp;#160; The &lt;strong&gt;Read-only Fields &lt;/strong&gt;setting allows you to identify any fields that should be rendered for display only.&amp;#160; Finally, the &lt;strong&gt;Control Mode&lt;/strong&gt; value tells SharePoint whether the controls should be rendered in New, Edit or Display mode.&amp;#160; Basically, this setting should match the function of the form you are customizing.&amp;#160; Since I'm customizing my Edit form, I've set mine to &amp;quot;Edit&amp;quot;.&amp;#160; Once you've set the values the way you want them, click Apply.&lt;/p&gt;  &lt;p&gt;The web part will still appear blank because we still need to provide the custom template that SharePoint will use to render our custom Edit form.&amp;#160; Create a new file called &amp;quot;CustomForms.ascx&amp;quot; in the &lt;font face="Consolas"&gt;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES &lt;/font&gt;folder.&amp;#160; SharePoint loads all the user control files in this folder when the application pool starts in IIS, enabling each &amp;quot;RenderingTemplate&amp;quot; to be referenced by ID.&amp;#160; Add the following markup to the new file:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="asp"&gt;&amp;lt;%@ Control Language=&amp;quot;C#&amp;quot;   AutoEventWireup=&amp;quot;false&amp;quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="asp"&gt;&amp;lt;%@Assembly Name=&amp;quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="asp"&gt;&amp;lt;%@Register TagPrefix=&amp;quot;Custom&amp;quot; Assembly=&amp;quot;CustomListForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7597e2c2cd876846&amp;quot; namespace=&amp;quot;CustomListForms&amp;quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="asp"&gt;&amp;lt;%@Register TagPrefix=&amp;quot;SharePoint&amp;quot; Assembly=&amp;quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot; namespace=&amp;quot;Microsoft.SharePoint.WebControls&amp;quot;%&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="asp"&gt;&amp;lt;%@Register TagPrefix=&amp;quot;SPHttpUtility&amp;quot; Assembly=&amp;quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot; namespace=&amp;quot;Microsoft.SharePoint.Utilities&amp;quot;%&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="asp"&gt;&amp;lt;%@ Register TagPrefix=&amp;quot;wssuc&amp;quot; TagName=&amp;quot;ToolBar&amp;quot; src=&amp;quot;~/_controltemplates/ToolBar.ascx&amp;quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="asp"&gt;&amp;lt;%@ Register TagPrefix=&amp;quot;wssuc&amp;quot; TagName=&amp;quot;ToolBarButton&amp;quot; src=&amp;quot;~/_controltemplates/ToolBarButton.ascx&amp;quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:RenderingTemplate&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CustomListForm&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SPAN&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;='part1'&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;wssuc:ToolBar&lt;/span&gt; &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-formtoolbar&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;toolBarTbltop&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;RightButtonSeparator&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;amp;nbsp;&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Template_RightButtons&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:SaveButton&lt;/span&gt;  &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:GoBackButton&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Template_RightButtons&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;wssuc:ToolBar&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:FormToolBar&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TABLE&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-formtable&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;margin-top: 8px;&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;border&lt;/span&gt;=&lt;span class="attr"&gt;0&lt;/span&gt; &lt;span class="attr"&gt;cellpadding&lt;/span&gt;=&lt;span class="attr"&gt;0&lt;/span&gt; &lt;span class="attr"&gt;cellspacing&lt;/span&gt;=&lt;span class="attr"&gt;0&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;=&lt;span class="attr"&gt;100&lt;/span&gt;%&amp;gt;&lt;br /&gt;            &amp;lt;&lt;span class="attr"&gt;&lt;font color="#800000"&gt;TR&lt;/font&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:CompositeField&lt;/span&gt; &lt;span class="attr"&gt;FieldName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Name&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ControlMode&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Display&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TR&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="border-top-width: 2px; border-left-width: 2px; border-left-color: black; border-bottom-width: 2px; border-bottom-color: black; border-top-color: black; background-color: yellow; border-right-width: 2px; border-right-color: black"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Custom:CustomListFormFieldIterator&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:FormComponent&lt;/span&gt; &lt;span class="attr"&gt;TemplateName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;AttachmentRows&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TABLE&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt; &lt;span class="attr"&gt;cellpadding&lt;/span&gt;=&lt;span class="attr"&gt;0&lt;/span&gt; &lt;span class="attr"&gt;cellspacing&lt;/span&gt;=&lt;span class="attr"&gt;0&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;=&lt;span class="attr"&gt;100&lt;/span&gt;%&amp;gt;&amp;lt;&lt;span class="attr"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-formline&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;IMG&lt;/span&gt; &lt;span class="attr"&gt;SRC&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;/_layouts/images/blank.gif&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;=&lt;span class="attr"&gt;1&lt;/span&gt; &lt;span class="attr"&gt;height&lt;/span&gt;=&lt;span class="attr"&gt;1&lt;/span&gt; &lt;span class="attr"&gt;alt&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TABLE&lt;/span&gt; &lt;span class="attr"&gt;cellpadding&lt;/span&gt;=&lt;span class="attr"&gt;0&lt;/span&gt; &lt;span class="attr"&gt;cellspacing&lt;/span&gt;=&lt;span class="attr"&gt;0&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;=&lt;span class="attr"&gt;100&lt;/span&gt;% &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;padding-top: 7px&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;=&lt;span class="attr"&gt;100&lt;/span&gt;%&amp;gt;&lt;br /&gt;            &amp;lt;&lt;span class="attr"&gt;&lt;font color="#800000"&gt;SharePoint:ItemHiddenVersion&lt;/font&gt;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;wssuc:ToolBar&lt;/span&gt; &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-formtoolbar&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;toolBarTbl&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;RightButtonSeparator&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;amp;nbsp;&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Template_Buttons&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:CreatedModifiedInfo&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Template_Buttons&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Template_RightButtons&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:SaveButton&lt;/span&gt;  &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:GoBackButton&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Template_RightButtons&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;wssuc:ToolBar&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TABLE&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;SPAN&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:AttachmentUpload&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;SharePoint:RenderingTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;font face="Consolas" color="#0000ff"&gt;&lt;/font&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you're wondering how I came up with this template, open up the &lt;font face="Consolas"&gt;DefaultTemplates.ascx&lt;/font&gt; file&amp;#160; in the &lt;font face="Consolas"&gt;CONTROLTEMPLATES&lt;/font&gt; folder and search for the &amp;quot;UserListForm&amp;quot; template.&amp;#160; It's basically identical, except I switched out the &lt;font face="Consolas"&gt;&amp;lt;SharePoint:ListFieldIterator&amp;gt;&lt;/font&gt; element for my &lt;font face="Consolas"&gt;&amp;lt;Custom:CustomListFormFieldIterator&amp;gt;&lt;/font&gt;.&amp;#160; As an interesting learning exercise, search the file for all usages of the &lt;font face="Consolas"&gt;ListFieldIterator&lt;/font&gt; and see where else SharePoint uses this control.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Once the template is in place, restart IIS (or recycle the application pool) so that SharePoint will see the new template.&amp;#160; The last thing you need to do is associate your new web part page as the Edit form for your list.&amp;#160; The easiest way to do this is with SharePoint Designer (but could also be done through a feature):&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Connect to your site in SharePoint Designer and expand the &amp;quot;Lists&amp;quot; node.&amp;#160; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Right-click on the tree view item for your list and select &amp;quot;Properties&amp;quot;. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click on the &amp;quot;Supporting Files&amp;quot; tab. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Change the &amp;quot;Content type specific forms&amp;quot; to &amp;quot;Item&amp;quot;. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;On the &amp;quot;Edit item form&amp;quot; setting, click the &amp;quot;Browse...&amp;quot; button and locate your web part page. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click OK to apply the changes. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here is how my dialog looks after I've configured custom forms for the &amp;quot;New&amp;quot; and &amp;quot;Edit&amp;quot; functionality:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/BKAlanna/SAZ-OaqqtKI/AAAAAAAAAfw/C2mz82qfZ9g/image15.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="340" alt="image" src="http://lh3.ggpht.com/BKAlanna/SAZ-OqqqtLI/AAAAAAAAAf4/WQMntd3USJg/image_thumb7.png" width="357" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Go back to your web browser and navigate to the list and edit an item.&amp;#160; Voil&amp;#224;! &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/BKAlanna/SAZ-PaqqtMI/AAAAAAAAAgA/VEWfh2OfIlc/image23.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="473" alt="image" src="http://lh4.ggpht.com/BKAlanna/SAZ-P6qqtNI/AAAAAAAAAgI/l0zVTbieZ_0/image_thumb11.png" width="733" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Attach File works!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/BKAlanna/SAZ-QaqqtOI/AAAAAAAAAgQ/nVpLTfJQxlA/image31%5B1%5D.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="237" alt="image" src="http://lh3.ggpht.com/BKAlanna/SAZ-QqqqtPI/AAAAAAAAAgY/tp3k8igZD38/image_thumb15.png" width="732" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Before saving...&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/BKAlanna/SAZ-Q6qqtQI/AAAAAAAAAgg/xnQ_dGhcCaM/image35.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="138" alt="image" src="http://lh6.ggpht.com/BKAlanna/SAZ-RaqqtRI/AAAAAAAAAgo/lhwtlA8HGF8/image_thumb17.png" width="730" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;After saving...&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/BKAlanna/SAZ-RqqqtSI/AAAAAAAAAgw/AjTOQtC0dKg/image39.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="138" alt="image" src="http://lh5.ggpht.com/BKAlanna/SAZ-SKqqtTI/AAAAAAAAAg4/Bu0DLZl_XRw/image_thumb19.png" width="730" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Delete works! (And it knows whether or not the Recycle Bin is enabled)&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/BKAlanna/SAZ-SqqqtUI/AAAAAAAAAhA/DegEVJslE8U/image43.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="123" alt="image" src="http://lh4.ggpht.com/BKAlanna/SAZ-S6qqtVI/AAAAAAAAAhI/M9Jd5wUVgQY/image_thumb21.png" width="385" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Optimistic updates work!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/BKAlanna/SAZ-TaqqtWI/AAAAAAAAAhQ/9FpP0ohlPqU/image47.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="181" alt="image" src="http://lh3.ggpht.com/BKAlanna/SAZ-TqqqtXI/AAAAAAAAAhY/6Nhxp_L2ZI8/image_thumb23.png" width="722" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Spelling works!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;(You get the idea)&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The template I've given here should work for most needs, so the only work needed to customize additional forms is basically to add a new web part page, add the web part and change the properties appropriately, and configure the SharePoint list to use the new form for new/edit/display functionality.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If there is interest, and time allowing, I'll post a follow up going over the details of the web part implementation and explore other possibilities beyond just rendering the usual templated SharePoint controls (i.e. inserting a map immediately after the address).&amp;#160; You are, after all, operating within the ASP.NET infrastructure so a lot more customization is possible.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Get the source and Setup executable &lt;u&gt;&lt;a href="http://mcelhanon.googlecode.com/files/CustomListForms.zip"&gt;here&lt;/a&gt;&lt;/u&gt;.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;UPDATE&lt;/font&gt;&lt;/strong&gt;: Based on a &lt;a href="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3194369&amp;amp;SiteID=17"&gt;response&lt;/a&gt; I got on the TechNet thread on using SharePoint Designer for this, I added another property to the web part: &lt;strong&gt;FieldTemplateOverrides&lt;/strong&gt;.&amp;#160; This allows you to specify a different template to use when rendering a particular field.&amp;#160; I changed my sample usage from above to exclude the State/Province and the ZIP/Postal Code columns, and then told the web part to use a different template for the &amp;quot;City&amp;quot; column (by setting the &lt;strong&gt;FieldTemplatesOverrides&lt;/strong&gt; property to &amp;quot;&lt;em&gt;City=CityStateZIPField&lt;/em&gt;&amp;quot;.&amp;#160; Here's what the two templates that I added to my &amp;quot;CustomTemplates.ascx&amp;quot; file look like:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:RenderingTemplate&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CityStateZIPField&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TD&lt;/span&gt; &lt;span class="attr"&gt;nowrap&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;valign&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;top&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;190px&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-formlabel&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;H3&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-standardheader&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;nobr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;City/State/ZIP&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-formvalidation&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; *&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;nobr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;H3&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TD&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TD&lt;/span&gt; &lt;span class="attr"&gt;valign&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;top&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ms-formbody&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;400px&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:TextField&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;FieldName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;City&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;DisplaySize&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;15&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;TemplateName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TextFieldNoBr&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;, &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:TextField&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;FieldName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;State/Province&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;DisplaySize&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;TemplateName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TextFieldNoBr&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:TextField&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;FieldName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ZIP/Postal Code&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;DisplaySize&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;TemplateName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TextFieldNoBr&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TD&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;SharePoint:RenderingTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SharePoint:RenderingTemplate&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TextFieldNoBr&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TextBox&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TextField&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;MaxLength&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;255&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Template&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;SharePoint:RenderingTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;  &lt;br /&gt;I had to add a special template for the TextField because the out-of-the-box template appends a &lt;font face="Consolas"&gt;&amp;lt;br&amp;gt;&lt;/font&gt; tag at the end.&amp;#160; Here's how the web part renders now:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/BKAlanna/SAkjc6qqtaI/AAAAAAAAAhs/zsjjr7PXNa0/image%5B8%5D.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="429" alt="image" src="http://lh5.ggpht.com/BKAlanna/SAkjdaqqtbI/AAAAAAAAAh0/4z013S3YvFY/image_thumb%5B3%5D.png" width="707" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I didn't handle the &amp;quot;Display&amp;quot; or &amp;quot;Required&amp;quot; cases, but I could augment the property to take multiple templates for each (kind of like how Excel accepts various formats for positive and negative values), but at that point I should probably look to creating a custom UI so that it doesn't get overly convoluted to use...&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5898028992635002784-1047787301669345236?l=g-m-a-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://g-m-a-c.blogspot.com/feeds/1047787301669345236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5898028992635002784&amp;postID=1047787301669345236' title='25 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/1047787301669345236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5898028992635002784/posts/default/1047787301669345236'/><link rel='alternate' type='text/html' href='http://g-m-a-c.blogspot.com/2008/04/customizing-sharepoint-2007-forms.html' title='Customizing SharePoint 2007 Forms Without Losing Attachments (et al.) Functionality'/><author><name>Geoff McElhanon</name><uri>http://www.blogger.com/profile/07260343209030527699</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp2.blogger.com/_QBVjqbHFN9Y/SAa_hKqqtZI/AAAAAAAAAhk/zxZZgHffRzw/S220/Avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/BKAlanna/SAZ-H6qqs_I/AAAAAAAAAeY/na802XxPE5A/s72-c/image_thumb11%5B1%5D.png' height='72' width='72'/><thr:total>25</thr:total></entry></feed>
