<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PeterKellner.net &#187; Visual Studio</title>
	<atom:link href="http://peterkellner.net/category/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net</link>
	<description>Microsoft Focussed, JavaScript (ExtJS, SenchaTouch &#38; Windows 8 Metro)</description>
	<lastBuildDate>Tue, 07 Feb 2012 21:14:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>With Visual Studio 2010 (and vs2011 preview) Fast Launch Not Helpful Often</title>
		<link>http://peterkellner.net/2011/11/12/with-visual-studio-2010-and-vs2011-preview-fast-launch-not-helpful-often/</link>
		<comments>http://peterkellner.net/2011/11/12/with-visual-studio-2010-and-vs2011-preview-fast-launch-not-helpful-often/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 17:06:58 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/11/12/with-visual-studio-2010-and-vs2011-preview-fast-launch-not-helpful-often/</guid>
		<description><![CDATA[&#160;  Let’s say I’ve created two Visual Studio Projects with the same name “WebApp” but reside in different directories as shown below (c:\temp\Proj1 and c:\temp\Proj2).&#160; I often call the project WebApp, however I want to keep the projects totally separate.&#160; Below are the File/New Project dialog examples.  &#160;      [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p>Let’s say I’ve created two Visual Studio Projects with the same name “WebApp” but reside in different directories as shown below (c:\temp\Proj1 and c:\temp\Proj2).&#160; I often call the project WebApp, however I want to keep the projects totally separate.&#160; Below are the File/New Project dialog examples.</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image10.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image_thumb9.png" width="558" height="145" /></a></p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image11.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image_thumb10.png" width="564" height="137" /></a></p>  <p>&#160;</p>  <p>Now, when I click start (this is with the vs2011 preview I’m demonstrating), I see the following:</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/11/image_thumb11.png" width="322" height="392" /></a></p>  <p>&#160;</p>  <p>I actually have to hover over each “WebApp.sln” to tell which project is which.&#160; I think that information should be in the pinned app itself, not require a hover over to tell which project it is.</p>  <p>Agree?&#160; Add your comment below and go to the following link to vote up my connect suggestion.</p>  <p><a href="https://connect.microsoft.com/VisualStudio/feedback/details/679081/should-have-vs-launch-shortcuts-inside-vs-recent-projects-because-run-as-admin">https://connect.microsoft.com/VisualStudio/feedback/details/679081/should-have-vs-launch-shortcuts-inside-vs-recent-projects-because-run-as-admin</a></p>  <p>From the comments, Microsoft said they would consider it for the next release, but it looks like it has not made it.&#160; Let’s try and change that!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/11/12/with-visual-studio-2010-and-vs2011-preview-fast-launch-not-helpful-often/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>With VS2010 Debugger, Step Into, From a Windows .Net App Directly into a Windows Azure Web Role Hosting a WCF Service In The Developer Fabric</title>
		<link>http://peterkellner.net/2011/06/07/with-vs2010-debugger-step-into-from-a-windows-net-app-directly-into-a-windows-azure-web-role-hosting-a-wcf-service-in-the-developer-fabric/</link>
		<comments>http://peterkellner.net/2011/06/07/with-vs2010-debugger-step-into-from-a-windows-net-app-directly-into-a-windows-azure-web-role-hosting-a-wcf-service-in-the-developer-fabric/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 21:52:09 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Azure Blob Storage]]></category>
		<category><![CDATA[Azure Deployment]]></category>
		<category><![CDATA[Azure Web Role]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/06/07/with-vs2010-debugger-step-into-from-a-windows-net-app-directly-into-a-windows-azure-web-role-hosting-a-wcf-service-in-the-developer-fabric/</guid>
		<description><![CDATA[&#160;  OK, I think this is the longest post title I’ve ever made, but if you understand it, you’ll know why it needs to be so long.&#160; I discovered this totally by accident.&#160; I would never ever have pressed F11 (step into) from a client side proxy and expect to get into anything but [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p>OK, I think this is the longest post title I’ve ever made, but if you understand it, you’ll know why it needs to be so long.&#160; I discovered this totally by accident.&#160; I would never ever have pressed F11 (step into) from a client side proxy and expect to get into anything but a bunch of ugly machine generated proxy code (especially with <a href="http://www.microsoft.com/windowsazure/">Azure</a>).&#160; To my total surprise, I landed right inside my <a href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx">WCF</a> service as if I had started the <a href="http://www.microsoft.com/en-us/cloud/developer/resource.aspx?resourceId=what-is-windows-azure&amp;fbid=flWeS4xmu1C&amp;WT.srch=1&amp;WT.mc_id=85C588D4-A353-4E3D-8824-823A9551AA51&amp;CR_SCC=200028978">Windows Azure Developer fabric</a> in debug mode and set a break point.</p>  <p>So, I’ll step through the process an show screen shots on the outside chance I was dreaming and can’t reproduce it. If I can, now I will have proof so I can do it again.&#160; Sorry for the work in progress code you will see.&#160; The point here is really the debugger and not the code I’m showing so try and ignore that.</p>  <p>OK, here we go.</p>  <p>Let’s assume you have a completely configured azure web role that is hosting a simple <a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation">WCF</a> service.&#160; When you start that web role and point at the service, you’ll get something like this: (just a note that I started the app fabric by deploying directly from <a href="http://www.microsoft.com/en-us/default.aspx">Microsoft</a> <a href="http://www.microsoft.com/visualstudio/en-us">Visual Studio 2010</a> with the start/run.&#160; I am using a debug profile but am <strong>NOT </strong>running in debug mode.&#160; If I do run the app fabric in debug mode, this does not work.</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image_thumb4.png" width="480" height="366" /></a></p>  <span id="more-1508"></span>  <p>&#160;</p>  <p>OK, now let’s run my app that has a <a href="http://visualstudiomagazine.com/articles/2011/06/01/pcnet_wcf-and-soa.aspx">WCF</a> client configured to connect to this service.&#160; The configuration is the normal “Add Service Reference” you would expect but I’m showing it any how just to be clear.</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image_thumb5.png" width="485" height="473" /></a></p>  <p>&#160;</p>  <p>Next, we simply Launch <a href="http://www.microsoft.com/visualstudio/en-us">Visual Studio 2010</a> in <a href="http://msdn.microsoft.com/en-us/library/sc65sadd.aspx">debug</a> mode and put a break point just before we cross over into the WCF service by calling the above proxy code.&#160; Here is what that screen looks like after the break point is hit and I’m about to step INTO.</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image_thumb6.png" width="616" height="198" /></a></p>    <p><font size="6">F11</font></p>  <p>&#160;</p>  <p>and…..</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/06/image_thumb7.png" width="657" height="265" /></a></p>  <p><font size="2"></font></p>  <p>There we are!!! right inside the source code that is my WCF service with everything working as if I had launched the site on it’s own, set a break point and waited.</p>  <p>&#160;</p>  <p>Truly amazing!!!&#160; I have nothing more to say.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/06/07/with-vs2010-debugger-step-into-from-a-windows-net-app-directly-into-a-windows-azure-web-role-hosting-a-wcf-service-in-the-developer-fabric/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another Nice DevExpress CodeRush Refactoring</title>
		<link>http://peterkellner.net/2010/07/04/coderush-factorings-introduce-lambda-using-statements/</link>
		<comments>http://peterkellner.net/2010/07/04/coderush-factorings-introduce-lambda-using-statements/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 16:42:26 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[CodeRush]]></category>
		<category><![CDATA[Refactor]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/07/04/coderush-factorings-introduce-lambda-using-statements/</guid>
		<description><![CDATA[For the last few days, I’ve been using DevExpress CodeRush and am finding some very useful refactorings.&#160; Many I’m not blogging about, but there are a few that I really like.&#160; In this post, I’m going to show just two of those refactorings that have been making my code much nicer and easier to write.&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>For the last few days, I’ve been using <a href="http://devexpress.com/">DevExpress</a> <a href="http://devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/">CodeRush</a> and am finding some very useful refactorings.&#160; Many I’m not blogging about, but there are a few that I really like.&#160; In this post, I’m going to show just two of those refactorings that have been making my code much nicer and easier to write.&#160; One is the “Introduce Using” refactoring, and the other is “Convert to Lambda Expression”.</p>  <p>Before I go into the details, I’d just like to disclose that when I was first writing the <a href="http://www.siliconvalley-codecamp.com/">Silicon Valley Code Camp</a> web site, I was an asp.net and c# newby.&#160; I’m not claiming wizard status now, but I have to admit that when I go back and look at some of the code I wrote back then (including what I’m showing below before the refactoring), it’s a little embarrassing.&#160; Silicon Valley Code Camp for me as “when I’m not doing real work” web site so I don’t really have the time to go back and clean things up.&#160; Now, with CodeRush, it’s easy to clean things up when I see them with very little effort.</p> <span id="more-1337"></span>  <h2>Introduce Using Statement Refactoring</h2>  <p>Here is the code I wrote 5+ years ago:</p>  <div id="codeSnippetWrapper">   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">SqlConnection conn = <span style="color: #0000ff">new</span> SqlConnection(connectionString);<br />conn.Open();<br /><br /><span style="color: #008000">// First, make a quick list of counts for each id that is unavailable and show</span><br /><span style="color: #008000">// not be shown</span><br /><span style="color: #0000ff">string</span> selectCount = <span style="color: #006080">@&quot;select VistaSlotsId FROM attendees <br />                     WHERE VistaSlotsId &gt;= 2 AND VistaSlotsId &lt;= 5 Group By VistaSlotsId <br />                     HAVING COUNT(*) &gt;= @MaxPerSlot  &quot;</span>;<br />List&lt;<span style="color: #0000ff">int</span>&gt; unavailableSlotsList = <span style="color: #0000ff">new</span> List&lt;<span style="color: #0000ff">int</span>&gt;();<br />SqlDataReader readerUnavailable = <span style="color: #0000ff">null</span>;<br />SqlCommand cmdUnAvailable = <span style="color: #0000ff">new</span> SqlCommand(selectCount, conn);<br />cmdUnAvailable.Parameters.Add(<span style="color: #006080">&quot;@MaxPerSlot&quot;</span>, SqlDbType.Int).Value = maxPerSlot;<br />readerUnavailable = cmdUnAvailable.ExecuteReader();<br /><span style="color: #0000ff">try</span><br />{<br />    <span style="color: #0000ff">while</span> (readerUnavailable.Read())<br />    {<br />        <span style="color: #0000ff">int</span> id = readerUnavailable.GetInt32(0);<br />        unavailableSlotsList.Add(id);<br />    }<br />}<br /><span style="color: #0000ff">finally</span><br />{<br />    <span style="color: #0000ff">if</span> (readerUnavailable != <span style="color: #0000ff">null</span>) readerUnavailable.Close();<br />}</pre>

  <br /></div>

<p>By placing the cursor over the “conn” on the top line of the code above, CodeRush gives us the following result:</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AnotherNiceDevExpressCodeRushRefactoring_8873/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AnotherNiceDevExpressCodeRushRefactoring_8873/image_thumb.png" width="507" height="233" /></a> </p>

<p>There are actually quite a few things happening here.</p>

<ol>
  <li>It is showing us in the top textbox what the using syntax will be </li>

  <li>It is crossing out the lines of code it will change </li>

  <li>It is teaching us a little about the using statement </li>
</ol>

<p>If I accept the changes, I get a nice refactoring.&#160; I can continue doing this with “using” for SqlCommand and SqlReader.&#160; I did need to move the SqlReader declaration inside the SqlCommand codeblock for this to work.&#160; Here is the final refactored code that took about 10 seconds.&#160; By hand, I’d say it would have taken me 3 minutes and I may have gotten it wrong which is why I would never do it before.&#160; Now, I’m confident I did not break my code.</p>

<div id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">using</span> (SqlConnection conn = <span style="color: #0000ff">new</span> SqlConnection(connectionString))<br />{<br />    conn.Open();<br />    <span style="color: #008000">// First, make a quick list of counts for each id that is unavailable and show</span><br />    <span style="color: #008000">// not be shown</span><br />    <span style="color: #0000ff">string</span> selectCount = <span style="color: #006080">@&quot;select VistaSlotsId FROM attendees <br />                                 WHERE VistaSlotsId &gt;= 2 AND VistaSlotsId &lt;= 5 Group By VistaSlotsId <br />                                 HAVING COUNT(*) &gt;= @MaxPerSlot  &quot;</span>;<br />    List&lt;<span style="color: #0000ff">int</span>&gt; unavailableSlotsList = <span style="color: #0000ff">new</span> List&lt;<span style="color: #0000ff">int</span>&gt;();<br />    <span style="color: #0000ff">using</span> (SqlCommand cmdUnAvailable = <span style="color: #0000ff">new</span> SqlCommand(selectCount, conn))<br />    {<br />        cmdUnAvailable.Parameters.Add(<span style="color: #006080">&quot;@MaxPerSlot&quot;</span>, SqlDbType.Int).Value = maxPerSlot;<br />        <span style="color: #0000ff">using</span> (SqlDataReader readerUnavailable = cmdUnAvailable.ExecuteReader())<br />        {<br />            <span style="color: #0000ff">try</span><br />            {<br />                <span style="color: #0000ff">while</span> (readerUnavailable.Read())<br />                {<br />                    <span style="color: #0000ff">int</span> id = readerUnavailable.GetInt32(0);<br />                    unavailableSlotsList.Add(id);<br />                }<br />            }<br />            <span style="color: #0000ff">finally</span><br />            {<br />                <span style="color: #0000ff">if</span> (readerUnavailable != <span style="color: #0000ff">null</span>)<br />                    readerUnavailable.Close();<br />            }<br />        }<br />    }</pre>&#160; </div>

<div>
  <br /></div>

<h2>Compress To Lambda Expression Refactoring</h2>

<p>A lot of the Silicon Valley Code Camp web site was written prior to the introduction of Lamba Expressions.&#160; If you recall, I wrote an MSDN article back in 2006 entitled <a href="http://peterkellner.net/2006/03/13/adding-personalization-via-profiles-to-the-objectdatasource-in-aspnet-20/">Adding Personalization via Profiles to the ObjectDataSource in ASP.NET 2.0.</a>&#160; <a href="http://blogs.tedneward.com/">Ted Neward</a> inspired a construct to cleverly sort the result list using delegates as shown in the screen shot (form that above post).</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AnotherNiceDevExpressCodeRushRefactoring_8873/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AnotherNiceDevExpressCodeRushRefactoring_8873/image_thumb_3.png" width="569" height="353" /></a> </p>

<p>&#160;</p>

<p>The code below is similar to the above but not quite the same.&#160; This is how it looks before the refactoring:</p>

<div id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">Comparison&lt;DataObjectSessionsOverview&gt; comparison = <span style="color: #0000ff">null</span>;<br />    <span style="color: #0000ff">switch</span> (sortDataBase)<br />    {<br />        <span style="color: #0000ff">case</span> <span style="color: #006080">&quot;Userfirstname&quot;</span>:<br />            comparison = <span style="color: #0000ff">new</span> Comparison&lt;DataObjectSessionsOverview&gt;(<br />               <span style="color: #0000ff">delegate</span>(DataObjectSessionsOverview lhs, DataObjectSessionsOverview rhs)<br />               {<br />                   <span style="color: #0000ff">return</span> lhs.Userfirstname.CompareTo(rhs.Userfirstname);<br />               }<br />             );<br />            <span style="color: #0000ff">break</span>;</pre>

  <br /></div>

<p>CodeRush suggests:</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AnotherNiceDevExpressCodeRushRefactoring_8873/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AnotherNiceDevExpressCodeRushRefactoring_8873/image_thumb_4.png" width="551" height="245" /></a> </p>

<p>Which then give us:</p>

<div id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">switch</span> (sortDataBase)<br />{<br />   <span style="color: #0000ff">case</span> <span style="color: #006080">&quot;Userfirstname&quot;</span>:<br />       comparison = (lhs, rhs) =&gt; lhs.Userfirstname.CompareTo(rhs.Userfirstname);<br />       <span style="color: #0000ff">break</span>;</pre>

  <br /></div>

<p>I like it!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/07/04/coderush-factorings-introduce-lambda-using-statements/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A Handy Refactoring with CodeRush (InLine Temp)</title>
		<link>http://peterkellner.net/2010/07/02/coderush-refactoring-inline-temp/</link>
		<comments>http://peterkellner.net/2010/07/02/coderush-refactoring-inline-temp/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 14:34:56 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CodeRush]]></category>
		<category><![CDATA[Refactor]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/07/02/coderush-refactoring-inline-temp/</guid>
		<description><![CDATA[I’ve recently started using CodeRush with Visual Studio 2010 and am so far very impressed with the convenience it adds to coding.&#160; One thing that is very clear is that the creators of CodeRush are real programmers and look very hard for patterns that us developers are constantly doing.&#160; As I run into these things [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve recently started using <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/">CodeRush</a> with <a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx">Visual Studio 2010</a> and am so far very impressed with the convenience it adds to coding.&#160; One thing that is very clear is that the creators of <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/">CodeRush</a> are real programmers and look very hard for patterns that us developers are constantly doing.&#160; As I run into these things that get my attention, I plan on blogging them.&#160; Some are just earth shattering, and others, just nice to have.&#160; This particular one is a nice to have.</p>  <p>So, say you have code like this:</p>  <p>&#160;</p>  <div>   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">var sessionAttendeeOds = <br />  <span style="color: #0000ff">new</span> SessionAttendeeODS();<br />listSessionAttendees = <br />  sessionAttendeeOds.GetByUsername(Context.User.Identity.Name);</pre>
</div>

<div>&#160;</div>
<span id="more-1335"></span>

<div>When I first wrote code, I often do it like this thinking that I may have more methods I’m going to call against the instantiated object.&#160; In this case, many years later, I’m looking at the code and want to condense it.&#160; With <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/">CodeRush</a>, it show me three little dots under the variable sessionAttendeeOds as follows.&#160; When I click on these three dots, I get the following screen.</div>

<p><a href="http://peterkellner.net/FilesForWebDownload/AHandyRefactoringwithCodeRushInLineTemp_6A97/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AHandyRefactoringwithCodeRushInLineTemp_6A97/image_thumb.png" width="405" height="156" /></a> </p>

<p>When I chose “InlineTemp”, the code changes to the following, make it easier to read.</p>

<div id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">listSessionAttendees = <br />                <span style="color: #0000ff">new</span> SessionAttendeeODS().GetByUsername(Context.User.Identity.Name);</pre>

  <br /></div>

<p>Again, this is not a huge deal, but small fixes like this will add up over time and make my code cleaner and more readable.&#160; CodeRush makes it so easy that I’m sure I’ll do this kind of thing more and more.</p>

<p>HTH’s.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/07/02/coderush-refactoring-inline-temp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A VS2010 Project Made From Post: How to: Host a WCF Service in a Managed Windows Service</title>
		<link>http://peterkellner.net/2010/06/18/wcf-service-in-managed-windows-service-vs2010-2/</link>
		<comments>http://peterkellner.net/2010/06/18/wcf-service-in-managed-windows-service-vs2010-2/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 14:37:33 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 4.0]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Windows Service]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/06/18/wcf-service-in-managed-windows-service-vs2010-2/</guid>
		<description><![CDATA[MSDN has a very nice article on how to create a windows service that hosts a Windows Communication Foundation (WCF) service.&#160; It explains all the details of doing this in a step by step fashion.&#160; One thing that I often find missing from these articles is the actual Visual Studio project that I can download [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/ms733069.aspx" target="_blank">MSDN has a very nice article</a> on how to create a windows service that hosts a <a href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx" target="_blank">Windows Communication Foundation (WCF)</a> service.&#160; It explains all the details of doing this in a step by step fashion.&#160; One thing that I often find missing from these articles is the actual Visual Studio project that I can download and play with.&#160; What I usually do is put that together myself (which I’m sure is the author’s intent).</p>  <p>To save anyone some time who wants to do the same thing, I’ve created a VS2010 project from the example, added a very simple Windows C# console application that consumes the service, as well as made some small changes in a very nice Windows Presentation Foundation (WPF) <a href="http://code.google.com/p/wpf-mvvm-calculator/" target="_blank">calculator project</a> so that the calculator does it operations inside the windows service rather than in the calculator itself.</p>  <p>In this article, I’ve attached the source code (with my small changes and additions) for you to work with and change as you like.</p> <span id="more-1332"></span>  <p>First, here is the project: </p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:d3a970ab-d487-417a-bf52-fd64c206e6d2" class="wlWriterEditableSmartContent"><p>Visual Studio 2010 Project <a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/WCFServiceInManagedWindowsService_3.zip" target="_blank">Project Zip Here</a></p></div>  <p>Now, let’s talk about the details</p>  <p>&#160;</p>  <h2>The Visual Studio 2010 Solution Itself</h2>  <p><a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_thumb_9.png" width="490" height="381" /></a> </p>  <p>There are three projects in this solution.&#160; The service itself which is called WCFServiceInmanagedWindowsService, Console Application and Calculator.</p>  <p>&#160;</p>  <h3>WCFServiceInManagedWindowsService Project</h3>  <p>&#160;</p>  <p>This project is really what is taken from the <a href="http://msdn.microsoft.com/en-us/library/ms733069.aspx" target="_blank">MSDN article</a>. It’s got almost no change and is primarily created by following the directions in the article.&#160; There are a couple batch files added for creating and deleting the service itself in the root of that project directory, but that’s about it.&#160; All the code is in a file called service.cs.</p>  <p>To Add the service, go to the “Service Reference”/”Add Service” Dialog and enter the address of the service (you can find it in the app.config file).</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_thumb_10.png" width="408" height="337" /></a> </p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_13.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_thumb_11.png" width="395" height="85" /></a> </p>  <p><a title="http://localhost:8000/ServiceModelSamples/service" href="http://localhost:8000/ServiceModelSamples/service">http://localhost:8000/ServiceModelSamples/service</a></p>  <p>Notice that the methods exposed are Add/Divide/Multiple and Subtract.</p>  <p>To start the actual service, after rebuilding the project, execute the bat file InstallService.bat in the root directory.&#160; Make sure you build the release version because this script installs the service from the release directory. Once started, you will see it in the services application as follows:</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_14.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_thumb_12.png" width="354" height="178" /></a> </p>  <p>Then, start the service by running the command: “net start WCFWindowsServiceSample”&#160; If you get the error: <em>“No connection could be made because the target machine actively refused it 127.0.0.1:8000”,</em> this likely means you did not start your service.</p>  <p>&#160;</p>  <h3>The Console Application</h3>  <p>The Console application is new and very simple. All you have to do is create a new windows c# console project, use the “Add Service” DialWCFWindowsServiceSampleog and point it at&#160; ( <a title="http://localhost:8000/ServiceModelSamples/service" href="http://localhost:8000/ServiceModelSamples/service">http://localhost:8000/ServiceModelSamples/service</a> ) as follows:</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_15.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_thumb_13.png" width="288" height="317" /></a> </p>  <p>Now, you can simply write a console app with the following code and you will be calling the service correctly.&#160; Here is the code:</p>  <p>&#160;</p>  <div id="codeSnippetWrapper">   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">class</span> Program<br />    {<br />        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)<br />        {<br />            var calculatorClient = <span style="color: #0000ff">new</span> CalculatorClient();<br /><br />            var answer = calculatorClient.Add(5, 4);<br />            Console.WriteLine(<span style="color: #006080">&quot;Answer to Adding 5 + 4: {0}&quot;</span>, answer);<br />            Console.ReadKey();<br /><br /><br />            <br />        }<br />    }</pre>

  <br /></div>

<p>And, when we run it, now surprise, we get 9!</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_16.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_thumb_14.png" width="244" height="120" /></a> </p>

<p>…</p>

<h3>The Calculator Application</h3>

<p>Just to show a real life use of the service, I grabbed the codeplex project <a title="http://code.google.com/p/wpf-mvvm-calculator/" href="http://code.google.com/p/wpf-mvvm-calculator/">http://code.google.com/p/wpf-mvvm-calculator/</a>.</p>

<p><a href="http://code.google.com/p/wpf-mvvm-calculator/"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_17.png" width="372" height="157" /></a> </p>

<p>Then, modifying a small section of code inside (after adding the service reference of course, just like we did in the above console project, we now have a calculator that adds by calling a service for the answer.&#160; Here is the modified code:</p>

<div id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">try</span><br />           {<br />               <span style="color: #008000">// Establish the connection to the Service</span><br />               var calculatorClient = <span style="color: #0000ff">new</span> CalculatorClient();<br />               var firstOperand = Convert.ToDouble(FirstOperand);<br />               var secondOperand = Convert.ToDouble(SecondOperand);<br /><br /><br /><br />               var stopwatch = <span style="color: #0000ff">new</span> Stopwatch();<br />               stopwatch.Start();<br /><br />               <span style="color: #0000ff">switch</span> (Operation)<br />               {<br />                   <span style="color: #0000ff">case</span> (<span style="color: #006080">&quot;+&quot;</span>):<br />                       result = calculatorClient.Add(firstOperand, secondOperand).ToString();<br />                       <span style="color: #0000ff">break</span>;<br /><br />                   <span style="color: #0000ff">case</span> (<span style="color: #006080">&quot;-&quot;</span>):<br />                       result = calculatorClient.Subtract(firstOperand, secondOperand).ToString();<br />                       <span style="color: #0000ff">break</span>;<br /><br />                   <span style="color: #0000ff">case</span> (<span style="color: #006080">&quot;*&quot;</span>):<br />                       result = calculatorClient.Multiply(firstOperand, secondOperand).ToString();<br />                       <span style="color: #0000ff">break</span>;<br /><br />                   <span style="color: #0000ff">case</span> (<span style="color: #006080">&quot;/&quot;</span>):<br />                       result = calculatorClient.Divide(firstOperand, secondOperand).ToString();<br />                       <span style="color: #0000ff">break</span>;<br />               }<br /><br />               stopwatch.Stop();</pre>

  <br /></div>

<p>And, when we run the calculator, it looks like this:</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_18.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AVS2010ProjectMadeFromPostHowtoHostaWCFS_C58D/image_thumb_15.png" width="333" height="232" /></a>&#160;</p>

<p>&#160;</p>

<h2>Conclusions</h2>

<p>In this post, we simply implemented the source as a <a href="http://www.microsoft.com/visualstudio/en-us">Visual Studio 2010</a> project from the MSDN article on how to build a windows service using WCF.&#160; It’s been pointed out that we are better off using named pipes for this kind of application for better performance, but our purpose here was just to elaborate on the existing application.</p>

<p>Hope this helps.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/06/18/wcf-service-in-managed-windows-service-vs2010-2/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Adding Speakers Page Template With Converters In Visual Studio 2010 Beta2 (Article 5 of 7)</title>
		<link>http://peterkellner.net/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/</link>
		<comments>http://peterkellner.net/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:20:35 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[RIA Services]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/</guid>
		<description><![CDATA[            &#160;        Title Of Each Article        Video Included With Each Post                  Part 1 [...]]]></description>
			<content:encoded><![CDATA[<table width="90%"><tbody>     <tr>       <td width="70">&#160;</td>        <td>Title Of Each Article</td>        <td style="width: 100px" width="150">Video Included With Each Post</td>     </tr>      <tr>       <td width="70">Part 1</td>        <td><a href="/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/">Introduction To RIA Services In Silverlight (This Article)</a></td>        <td style="width: 100px" width="150">7 Minutes</td>     </tr>      <tr>       <td width="70">Part 2</td>        <td><a href="/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/">Basic RIA Services And DataGrid With&#160; VS 2010 Tooling</a></td>        <td style="width: 100px" width="150">14 Minutes</td>     </tr>      <tr>       <td width="70">Part 3</td>        <td><a href="/2010/01/23/adding-a-datagrid-with-connect-the-dots-databinding-in-vs-2010-article-3-of-7/">Adding A DataGrid With Connect The Dots DataBinding in VS 2010</a></td>        <td style="width: 100px" width="150">13 Minutes</td>     </tr>      <tr>       <td width="70">Part 4</td>        <td><a href="/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/">Adding a Navigation Page to a Silverlight Business Application Template</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 5</td>        <td><a href="/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/">Adding Speakers Page Template With Converters In Visual Studio 2010 Beta2</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 6</td>        <td><a href="/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/">Adding A Sessions Page That Includes a Query Parameter In Silverlight VS2010 Beta2</a></td>        <td style="width: 100px" width="150">10 Minutes</td>     </tr>      <tr>       <td width="70">Part 7</td>        <td><a href="/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/">Basic Authentication and Authorization In RIA Services</a></td>        <td style="width: 100px" width="150">5 Minutes</td>     </tr>   </tbody></table>  <p>&#160;</p>  <br /><img src="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P5_AddingSpeakerPageTemplateWithConvertsAndHandler_Thumb.jpg" alt="media" /><br />
  <p>&#160;</p>  <p>This article will follow the previous article and go through the process of adding Converter’s for changing both the Id column and the Image column.&#160; Basically, what we saw in the previous article was a DataGrid that was created and looked as follows.&#160; (notice the Id column and the PKID columns which are highlighted.&#160; Then, we will add a a DisplayItemTemplate that will format the page and make it look good.</p> <span id="more-481"></span>  <p>&#160;</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb.png" width="411" height="354" /></a></p>  <p>&#160;</p>  <p>What we are going to want to do is convert the Id column’s data from something that looks like “777” to “/Sessions?SpeakerId=777”.&#160; We also will change the PKID column to change from showing a value like “222f32f83-8811” to http://localhost:52879/DisplayImage.ashx?sizex=60&amp;PKID=222f32f83-8811”.&#160; Then, we will apply a template that will make the page look like the following:</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_3.png" width="268" height="319" /></a></p>  <p>&#160;</p>  <p>So, let’s get started.</p>  <p>&#160;</p>  <p>First, we need to add two converters to the project.&#160; Both are straight forward and I will not give much explanation besides saying they do exactly what was mentioned in the paragraph below the above picture.</p>  <p><span style="text-decoration: underline"></span>&#160;</p>  <p><span style="text-decoration: underline">Image Converter:</span></p><br />   <div class="csharpcode">   <pre class="alt"><span class="kwrd">namespace</span> BusinessApplicationSVCodeCamp</pre>

  <pre>{</pre>

  <pre class="alt">    <span class="kwrd">public</span> <span class="kwrd">class</span> ImageConverter : IValueConverter</pre>

  <pre>    {</pre>

  <pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">object</span> ConvertBack(<span class="kwrd">object</span> <span class="kwrd">value</span>, Type targetType, <span class="kwrd">object</span> parameter, System.Globalization.CultureInfo culture)</pre>

  <pre>        {</pre>

  <pre class="alt">            <span class="kwrd">throw</span> <span class="kwrd">new</span> NotImplementedException();</pre>

  <pre>        }</pre>

  <pre class="alt">&#160;</pre>

  <pre>        <span class="kwrd">public</span> <span class="kwrd">object</span> Convert(<span class="kwrd">object</span> <span class="kwrd">value</span>, Type targetType, <span class="kwrd">object</span> parameter, System.Globalization.CultureInfo culture)</pre>

  <pre class="alt">        {</pre>

  <pre>            <span class="kwrd">string</span> PKID = <span class="kwrd">value</span>.ToString();</pre>

  <pre class="alt">&#160;</pre>

  <pre>            var s = Application.Current.Host.Source;</pre>

  <pre class="alt">            <span class="kwrd">int</span> horizontalSize = 60;</pre>

  <pre>            <span class="kwrd">string</span> path = String.Format(<span class="str">&quot;{0}://{1}:{2}/DisplayImage.ashx?sizex={3}&amp;PKID={4}&quot;</span>,</pre>

  <pre class="alt">                s.Scheme, s.Host, s.Port, horizontalSize, PKID);</pre>

  <pre>&#160;</pre>

  <pre class="alt">            <span class="kwrd">return</span> path;</pre>

  <pre>        }</pre>

  <pre class="alt">    }</pre>

  <pre>}</pre>
</div>
<br />
<p><span style="text-decoration: underline">Hyperlink Converter:</span></p>
<pre class="csharpcode"><span class="kwrd"></span>&#160;</pre>

<pre class="csharpcode"><span class="kwrd">namespace</span> BusinessApplicationSVCodeCamp
{
    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// NavigateUri=&quot;/Sessions?SpeakerId=2000&quot; is what we want</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="kwrd">public</span> <span class="kwrd">class</span> HyperLinkSessionsFormatter : IValueConverter
    {
        <span class="kwrd">public</span> <span class="kwrd">object</span> ConvertBack(<span class="kwrd">object</span> <span class="kwrd">value</span>, Type targetType, <span class="kwrd">object</span> parameter, System.Globalization.CultureInfo culture)
        {
            <span class="kwrd">throw</span> <span class="kwrd">new</span> NotImplementedException();
        }

        <span class="kwrd">public</span> <span class="kwrd">object</span> Convert(<span class="kwrd">object</span> <span class="kwrd">value</span>, Type targetType, <span class="kwrd">object</span> parameter, System.Globalization.CultureInfo culture)
        {
            <span class="kwrd">string</span> sessionId = <span class="kwrd">value</span>.ToString();
            <span class="kwrd">string</span> path = String.Format(<span class="str">&quot;/Sessions?SpeakerId={0}&quot;</span>,sessionId);
            <span class="kwrd">return</span> path;
        }

    }
}</pre>

<pre class="csharpcode">&#160;</pre>

<p>Next, we need to add these converters to our Visual Studio 2010 Beta2 project as resources so we can use them in the DataGrid.&#160; To do this, we use a very cool new feature in VS2010.&#160; It’s a little indirect how we do this, but ultimately, it does make sense.&#160; Just not very discoverable.&#160; What we do is we bring up the properties editor for the DataGrid.&#160; Notice below we are showing an icon next to the word “(Collection)”.&#160; This is the icon you click that brings up the Collection Editors: Columns dialog.</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_4.png" width="659" height="465" /></a></p>

<p>&#160;</p>

<p>How on the highlighted “Binding” property of the “idColumn”, you click the databinding icon and you will get the following binding dialog.</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_5.png" width="407" height="244" /></a></p>

<p>&#160;</p>

<p>chose “Apply Data Binding” and you’ll get the following:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_6.png" width="404" height="257" /></a></p>

<p>&#160;</p>

<p>Nothing has to be done to the Source property.&#160; This is already set to the the DomainDataSourceView we want.&#160; The Path is already set to Id, which is also correct.&#160; This all happened when we did the “Connect the dots” databinding with RIA Services.&#160; That is, when we dragged the domain data service on top of the DataGrid.&#160; We will need to set the Converter though so click on the currently unexpanded “Converters&quot; control and you will see:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_7.png" width="464" height="311" /></a></p>

<p>&#160;</p>

<p>What this is telling us is that in the Presentation1 project, we have the two converters available to us.&#160; We will need to add these to the project.&#160; To do that, we have to do it one at a time.&#160; First, click on HyperLinkSessionFormatter and you will see the following dialog.</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_8.png" width="462" height="304" /></a></p>

<p>&#160;</p>

<p>When you press “Create New”, you will get a choice of which xaml to put the resource in as follows:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_9.png" width="461" height="303" /></a></p>

<p>&#160;</p>

<p>By default, it will put it in your current Navigation Page (Speakers.xaml), however, if you look at the drop down:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_10.png" width="244" height="132" /></a></p>

<p>&#160;</p>

<p>you’ll see that you can also put in other xaml files that may make more sense.&#160; In our case, we are putting it in the Speakers.xaml file and when we press “OK”, it creates xaml as follows.</p>

<pre class="csharpcode"><span class="kwrd"></span>&#160;</pre>

<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">navigation:Page.Resources</span><span class="kwrd">&gt;</span>
   <span class="kwrd">&lt;</span><span class="html">my1:HyperLinkSessionsFormatter</span> <span class="attr">x:Key</span><span class="kwrd">=&quot;HyperLinkSessionsFormatter1&quot;</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">navigation:Page.Resources</span><span class="kwrd">&gt;</span></pre>

<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>

<p>or</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_11.png" width="399" height="269" /></a></p>

<p>&#160;</p>

<p>It also dropped in a namespace definition for us at the top of the file that looks like the following to reference the my1 prefix:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_12.png" width="402" height="317" /></a></p>

<p>&#160;</p>

<p>It seems like quite a few steps, however in practice, it’s very quick.&#160; I won’t go through the same steps again, but you need to add the ImageFormatter converter the same way (see busy screen shot below for all steps combined into one).</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_13.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_13.png" width="398" height="245" /></a></p>

<p>&#160;</p>

<p>Now, we’ve got xaml with two converters:</p>

<pre class="csharpcode">&#160;</pre>

<pre class="csharpcode">&lt;navigation:Page.Resources&gt;
        &lt;my1:HyperLinkSessionsFormatter x:Key=<span class="str">&quot;HyperLinkSessionsFormatter1&quot;</span> /&gt;
        &lt;my1:ImageConverter x:Key=<span class="str">&quot;ImageConverter1&quot;</span> /&gt;
&lt;/navigation:Page.Resources&gt;</pre>

<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>

<p>And, the columns of the DataGrid are bound to them correctly.&#160; The xaml for that looks as follows:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_14.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_14.png" width="434" height="183" /></a></p>

<p>&#160;</p>

<p>This is hugely convenient, and not very error prone which as far as I’m concerned is very nice.</p>

<p>&#160;</p>

<p>So, now when we run the page, we get the following:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_15.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_15.png" width="829" height="293" /></a></p>

<p>&#160;</p>

<p>Ugly, but you can see where we are headed.&#160; Now, we create a DataTemplate (or we get Michael Scherotter to help us create one) that looks like the following:</p>

<pre class="csharpcode"><span class="kwrd"></span>&#160;</pre>

<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">DataTemplate</span> <span class="attr">x:Key</span><span class="kwrd">=&quot;SpeakersItemTemplate&quot;</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Grid</span> <span class="kwrd">&gt;</span>
        <span class="rem">&lt;!--&lt;frameworkElement Margin=&quot;left,top,right,bottom  --&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">StackPanel</span> <span class="attr">d:LayoutOverrides</span><span class="kwrd">=&quot;Height&quot;</span> <span class="attr">Margin</span><span class="kwrd">=&quot;68,5,5,5&quot;</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">StackPanel</span> <span class="attr">Orientation</span><span class="kwrd">=&quot;Horizontal&quot;</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">x:Name</span><span class="kwrd">=&quot;FirstName&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;{Binding UserFirstName}&quot;</span>
                           <span class="attr">Margin</span><span class="kwrd">=&quot;0,0,6,0&quot;</span> <span class="attr">FontFamily</span><span class="kwrd">=&quot;Trebuchet MS&quot;</span> <span class="attr">FontSize</span><span class="kwrd">=&quot;16&quot;</span>
                           <span class="attr">FontWeight</span><span class="kwrd">=&quot;Bold&quot;</span><span class="kwrd">/&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">x:Name</span><span class="kwrd">=&quot;LastName&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;{Binding UserLastName}&quot;</span>
                           <span class="attr">FontFamily</span><span class="kwrd">=&quot;Trebuchet MS&quot;</span> <span class="attr">FontSize</span><span class="kwrd">=&quot;16&quot;</span> <span class="attr">FontWeight</span><span class="kwrd">=&quot;Bold&quot;</span><span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">StackPanel</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">HyperlinkButton</span>
                <span class="attr">NavigateUri</span><span class="kwrd">=&quot;{Binding Id, Converter={StaticResource HyperLinkSessionsFormatter1}}&quot;</span>
                <span class="attr">Content</span><span class="kwrd">=&quot;Sessions&quot;</span><span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">x:Name</span><span class="kwrd">=&quot;Description&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;{Binding UserBio}&quot;</span>
                       <span class="attr">TextWrapping</span><span class="kwrd">=&quot;Wrap&quot;</span> <span class="attr">FontFamily</span><span class="kwrd">=&quot;Trebuchet MS&quot;</span> <span class="attr">FontSize</span><span class="kwrd">=&quot;12&quot;</span><span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">StackPanel</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Image</span>  <span class="attr">HorizontalAlignment</span><span class="kwrd">=&quot;Left&quot;</span> <span class="attr">Width</span><span class="kwrd">=&quot;60&quot;</span> <span class="attr">VerticalAlignment</span><span class="kwrd">=&quot;Top&quot;</span>
                <span class="attr">Source</span><span class="kwrd">=&quot;{Binding Path=PKID, Converter={StaticResource ImagePathConverter1}}&quot;</span>  <span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Image</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">HyperlinkButton</span>  <span class="attr">Content</span><span class="kwrd">=&quot;WebSite&quot;</span>  <span class="attr">TargetName</span><span class="kwrd">=&quot;_blank&quot;</span>
                          <span class="attr">NavigateUri</span><span class="kwrd">=&quot;{Binding UserWebSite}&quot;</span> <span class="attr">VerticalAlignment</span><span class="kwrd">=&quot;Top&quot;</span>
                          <span class="attr">HorizontalAlignment</span><span class="kwrd">=&quot;Right&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Grid</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">DataTemplate</span><span class="kwrd">&gt;</span></pre>

<p>&#160;</p>

<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->Then, when we add a listbox, rather than the DataGrid and bind it the same</p>

<pre class="csharpcode"><span class="kwrd"></span>&#160;</pre>

<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">ListBox</span> <span class="attr">Height</span><span class="kwrd">=&quot;600&quot;</span>
         <span class="attr">ItemsSource</span><span class="kwrd">=&quot;{Binding ElementName=speakersShort2009DomainDataSource, Path=Data}&quot;</span>
         <span class="attr">ItemTemplate</span><span class="kwrd">=&quot;{StaticResource SpeakersItemTemplate}&quot;</span>
         <span class="attr">ScrollViewer</span>.<span class="attr">HorizontalScrollBarVisibility</span><span class="kwrd">=&quot;Disabled&quot;</span><span class="kwrd">/&gt;</span></pre>

<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>

<p>We get something that looks pretty nice:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_16.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingNavigationandImagesUsingVisualStud_C695/image_thumb_16.png" width="383" height="457" /></a></p>

<p>&#160;</p>

<p>That’s it for this article.&#160; In the next article we will actually talk about what happens when the Session hyperlink is pressed.&#160; We know it will take us to the Sessions page, but how it filters the Sessions is worth reading about.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<enclosure url="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P5_AddingSpeakerPageTemplateWithConvertsAndHandler.flv" length="1" type="video/x-flv"/>
	</item>
		<item>
		<title>Adding a Navigation Page to a Silverlight Business Application Template (Article 4 of 7)</title>
		<link>http://peterkellner.net/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/</link>
		<comments>http://peterkellner.net/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:16:49 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[RIA Services]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/</guid>
		<description><![CDATA[            &#160;        Title Of Each Article        Video Included With Each Post                  Part 1 [...]]]></description>
			<content:encoded><![CDATA[<table width="90%"><tbody>     <tr>       <td width="70">&#160;</td>        <td>Title Of Each Article</td>        <td style="width: 100px" width="150">Video Included With Each Post</td>     </tr>      <tr>       <td width="70">Part 1</td>        <td><a href="/2010/01/20/riaservices-silverlight-4-tutorial-svcc-part1of7-introduction/">Introduction To RIA Services In Silverlight (This Article)</a></td>        <td style="width: 100px" width="150">7 Minutes</td>     </tr>      <tr>       <td width="70">Part 2</td>        <td><a href="/2010/01/25/basic-ria-services-and-datagrid-with-vs-2010-tooling-article-2-of-7/">Basic RIA Services And DataGrid With&#160; VS 2010 Tooling</a></td>        <td style="width: 100px" width="150">14 Minutes</td>     </tr>      <tr>       <td width="70">Part 3</td>        <td><a href="/2010/01/23/adding-a-datagrid-with-connect-the-dots-databinding-in-vs-2010-article-3-of-7/">Adding A DataGrid With Connect The Dots DataBinding in VS 2010</a></td>        <td style="width: 100px" width="150">13 Minutes</td>     </tr>      <tr>       <td width="70">Part 4</td>        <td><a href="/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/">Adding a Navigation Page to a Silverlight Business Application Template</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 5</td>        <td><a href="/2010/01/25/adding-speakers-page-template-with-converters-in-visual-studio-2010-beta2-article-5-of-7/">Adding Speakers Page Template With Converters In Visual Studio 2010 Beta2</a></td>        <td style="width: 100px" width="150">11 Minutes</td>     </tr>      <tr>       <td width="70">Part 6</td>        <td><a href="/2010/01/25/adding-a-sessions-page-that-includes-a-query-parameter-in-silverlight-vs2010-article-6-of-7/">Adding A Sessions Page That Includes a Query Parameter In Silverlight VS2010 Beta2</a></td>        <td style="width: 100px" width="150">10 Minutes</td>     </tr>      <tr>       <td width="70">Part 7</td>        <td><a href="/2010/01/25/authentication-and-authorization-using-ria-services-article-7-of-7/">Basic Authentication and Authorization In RIA Services</a></td>        <td style="width: 100px" width="150">5 Minutes</td>     </tr>   </tbody></table>  <br />  <br /><img src="http://video.peterkellner.net//video/RIAServicesBayNet20090120/P4_AddingNavigationImage_Thumb.jpg" alt="media" /><br />
 <br /> <p>Well, if you have gotten this far in the series, you’ve probably realized I’ve gotten my articles and video’s a little out of sync.&#160; The video attached here goes through the full process of building an application from scratch while adding a navigation page.&#160; The process was somewhat explained in the previous article.&#160; I’ve kept the title the same because that is what the video actually shows. </p> <span id="more-480"></span>  <p>I won’t go through all the details again, however, what you will get at the end is a new speakers page which is just another tab on the home page that looks like the following.</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/AddingaNavigationPagetoaSilverlightBusin_CD03/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AddingaNavigationPagetoaSilverlightBusin_CD03/image_thumb.png" width="404" height="347" /></a></p>  <p>In the next section, we will go through adding a SpeakerPageTemplate to style it and have it show up with actual pictures and hyperlinks.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/01/25/adding-a-navigation-page-to-a-silverlight-business-application-template-article-4-of-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<enclosure url="http://video.peterkellner.net/video/RIAServicesBayNet20090120/P4_AddingNavigationImage.flv" length="1" type="video/x-flv"/>
	</item>
		<item>
		<title>I Love FinalBuilder from VSoft Technologies!</title>
		<link>http://peterkellner.net/2009/11/02/finalbuilder-review-svn-buildsystems/</link>
		<comments>http://peterkellner.net/2009/11/02/finalbuilder-review-svn-buildsystems/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 00:47:51 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Build Products]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Sql Server 2008]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/11/02/finalbuilder-review-svn-buildsystems/</guid>
		<description><![CDATA[&#160;  For the past couple years, I’ve used a product called FinalBuilder from VSoft Technologies to automate my build processes.&#160; Since I’ve been building web sites (about the past 5 years or so), one of the biggest hassles is maintaining them.&#160; That is, updating the databases, deploying the web site, automating backups, etc.&#160; I’ve [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p>For the past couple years, I’ve used a product called FinalBuilder from <a href="http://www.finalbuilder.com/home.aspx">VSoft Technologies</a> to automate my build processes.&#160; Since I’ve been building web sites (about the past 5 years or so), one of the biggest hassles is maintaining them.&#160; That is, updating the databases, deploying the web site, automating backups, etc.&#160; I’ve used several products like <a href="http://www.finalbuilder.com/home.aspx">FinalBuilder</a> (including Cruise Control), and to be honest, none of them come close to the quality of FinalBuilder.</p>  <p>Basically, the way the product works is that you create a “project” file using the FinalBuilder IDE.&#160; That project file has “Actions” in it which do things like “ftp” files to servers, rename files, iterate over sql scripts, parse and update files, checkout from source control, as well as hundreds of other convenient functions.&#160; You then execute that “script” file and all the magic happens.</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/ILoveFinalBuilderfromVSoftTechnologies_11360/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/ILoveFinalBuilderfromVSoftTechnologies_11360/image_thumb.png" width="244" height="181" /></a></p> <span id="more-376"></span>  <p>Then, VSoft has another product called FinalBuilder Server, which is really an asp.net web site that you run on your server.&#160; That running web site can take one of your FinalBuilder scripts, and run it through a really nice dashboard (web page). </p>  <p><a href="http://peterkellner.net/FilesForWebDownload/ILoveFinalBuilderfromVSoftTechnologies_11360/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/ILoveFinalBuilderfromVSoftTechnologies_11360/image_thumb_3.png" width="244" height="140" /></a></p>  <p>In my current scenario, I have 5 different web sites I can publish simply by pushing a button.&#160; I log into the web page (dashboard), press “Start Build”, and behind the scenes this is what happens:</p>  <ul>   <li>A new temporary directory is created </li>    <li>All My source code is exported from <a href="http://subversion.org/">subversion</a> into that directory </li>    <li>All My Visual Studio Solutions are built </li>    <li>All the config files (web.config,app.config, etc.) are updated with appropriate parameters (connection strings, etc.) </li>    <li>The Web Site is copied to the correct location </li>    <li>A Backup of the source is created an zipped into an archive directory </li>    <li>The temporary directory and all it’s files are deleted </li> </ul>  <p>Of course, I really do more than this, but you get the basic idea.&#160; It’s wonderful.&#160; It’s not free, but worth every penny (not to mention the support is awesome).</p>  <p>Hope you get a chance to try it.&#160; Here is a link to their site:</p>  <p><a title="http://www.finalbuilder.com/home.aspx" href="http://www.finalbuilder.com/home.aspx">http://www.finalbuilder.com/home.aspx</a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/11/02/finalbuilder-review-svn-buildsystems/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2008 Show All Files Does Not Always Work For Me</title>
		<link>http://peterkellner.net/2009/10/30/visualstudio2008-show-all-files-wifi-gogoinflight/</link>
		<comments>http://peterkellner.net/2009/10/30/visualstudio2008-show-all-files-wifi-gogoinflight/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 21:30:24 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/10/30/visualstudio2008-show-all-files-wifi-gogoinflight/</guid>
		<description><![CDATA[&#160;  Not sure how many times I’ve pressed the “Show All Files” menu choice on a Visual Studio 2008 Project and nothing happens.&#160; Well, I think I have finally found the pattern.  My guess is that you actually have to be clicked on the solution itself for the Show All Files to work.&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p>Not sure how many times I’ve pressed the “Show All Files” menu choice on a <a href="http://www.microsoft.com/visualstudio/en-us/default.mspx">Visual Studio 2008</a> Project and nothing happens.&#160; Well, I think I have finally found the pattern.</p>  <p>My guess is that you actually have to be clicked on the solution itself for the Show All Files to work.&#160; I think I’m usually on a directory inside the project and it doesn’t work. That is, I may be inside the /bin directory and expect that if I click “Show All Files” that I will see all the files in the bin directory (like the .config files).</p> <span id="more-375"></span>  <p>So, post back if you know more about this.&#160; This is just my best guess.</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/VisualStudio2008ShowAllFilesDoesNotAlway_C950/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/VisualStudio2008ShowAllFilesDoesNotAlway_C950/image_thumb.png" width="244" height="163" /></a></p>  <p>By the way, I’m blogging this in turbulence American Airlines flight 16 from San Francisco To New York City (JFK).&#160; <a href="http://www.gogoinflight.com/">Wifi</a> in the air is working great!!!</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/VisualStudio2008ShowAllFilesDoesNotAlway_C950/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/VisualStudio2008ShowAllFilesDoesNotAlway_C950/image_thumb_3.png" width="484" height="228" /></a></p>  <p><a title="http://flightaware.com/live/flight/AAL16" href="http://flightaware.com/live/flight/AAL16">http://flightaware.com/live/flight/AAL16</a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/10/30/visualstudio2008-show-all-files-wifi-gogoinflight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Automate a Simple Deploy Using DataDude (Visual Studio 2008 Database Edition)</title>
		<link>http://peterkellner.net/2009/10/24/datadude-vs2008-deploy-shortcut/</link>
		<comments>http://peterkellner.net/2009/10/24/datadude-vs2008-deploy-shortcut/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 15:38:15 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/10/24/datadude-vs2008-deploy-shortcut/</guid>
		<description><![CDATA[Not sure why this was hard, but I wanted to make a trivial command file to deploy my database (or any change to it).&#160; For those of you that don’t know the DataDude project, I have to say it’s one of the coolest tools that has come out the Microsoft Visual Studio Team for a [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure why this was hard, but I wanted to make a trivial command file to deploy my database (or any change to it).&#160; For those of you that don’t know the <a href="http://peterkellner.net/2009/01/17/visual-studio-database-edition-review-sqlserver2008/">DataDude project</a>, I have to say it’s one of the coolest tools that has come out the Microsoft Visual Studio Team for a while.&#160; Basically, in a nutshell, what it does is split’s your database into hundreds of little files.&#160; One for each table, key, foreign key, user, role, etc.&#160; Then, since it is a standard <a href="http://www.microsoft.com/visualstudio/en-us/products/teamsystem/default.mspx">VS2008</a> project, you can keep those files and the project under source control.&#160; The big benefit is that multiple team members can change files and check them in, and everyone’s schema is kept up to date.</p> <span id="more-372"></span>  <p>So, how does the up to date work?&#160; the way it works is when you get the latest from your version control, you simply right click on the vs2008 project and say “Deploy”.</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/HowtoAutomateaSimpleDeployUsingDataDudeV_777E/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/HowtoAutomateaSimpleDeployUsingDataDudeV_777E/image_thumb.png" width="358" height="277" /></a></p>  <p>It’s kind of a hassle though because you have to open the project first, the don this.</p>  <p>Here is a simple one line cmd file that you can use to do this task for you.</p>  <pre class="csharpcode">C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Deploy 
  /p:Configuration=<span class="str">&quot;Debug&quot;</span>;Platform=<span class="str">&quot;Any CPU&quot;</span> /v:normal /m 
  <span class="str">&quot;data\ThreePLogicDatabase\ThreePLogicDatabase.dbproj&quot;</span>
pause</pre>

<p>
  <br /></p>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<pre class="csharpcode">That’s it!  hope this helps.</pre>

<p>
  <br /></p>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/10/24/datadude-vs2008-deploy-shortcut/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Awesome Scrum Developer Training coming to Silicon Valley Microsoft Campus</title>
		<link>http://peterkellner.net/2009/10/14/scrum-training-course-mountainview-richard-hundhausen/</link>
		<comments>http://peterkellner.net/2009/10/14/scrum-training-course-mountainview-richard-hundhausen/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 04:02:34 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/10/14/scrum-training-course-mountainview-richard-hundhausen/</guid>
		<description><![CDATA[Several years ago, I was invited to a special showing of what was going to be the new SqlServer 2008 database in San Francisco.&#160; I had expected a sales demo but was hugely surprised by the quality of the presenter and his deep understanding of issues facing real developers like us.&#160; Over the years, I’ve [...]]]></description>
			<content:encoded><![CDATA[<p>Several years ago, I was invited to a special showing of what was going to be the new SqlServer 2008 database in San Francisco.&#160; I had expected a sales demo but was hugely surprised by the quality of the presenter and his deep understanding of issues facing real developers like us.&#160; Over the years, I’ve gotten to know this presenter (<a href="http://blog.hundhausen.com/">Richard Hundhausen</a>) and the other work he’s been involved in. </p> <span id="more-365"></span>  <p>Richard has been developing a special training course for the Scrum development team.&#160; He’s giving this course called “Scrum Developer Training” at the Microsoft Technology Center in just a few weeks (11/2-11/6).&#160; If you have the opportunity, I can’t imagine a better thing to do to help improve you skills at being productive working in an engineering team.&#160; You can register at the following URL: </p>  <p><a title="http://www.regonline.com/Checkin.asp?EventId=780690" href="http://www.regonline.com/Checkin.asp?EventId=780690">http://www.regonline.com/Checkin.asp?EventId=780690</a></p>  <p>You can read more about the course here:&#160; <a title="http://www.accentient.com/scrum.aspx" href="http://www.accentient.com/scrum.aspx">http://www.accentient.com/scrum.aspx</a></p>  <p>I hope you can make it!</p>  <p><a href="http://www.accentient.com/scrum.aspx"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/AwesomeScrumDeveloperTrainingcomingtoSil_125F0/image.png" width="389" height="438" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/10/14/scrum-training-course-mountainview-richard-hundhausen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Some Really Cool LINQ to Help Performance and Show Line Thickness</title>
		<link>http://peterkellner.net/2009/09/18/linq-groupby-grouplist-uniquesort-mapping/</link>
		<comments>http://peterkellner.net/2009/09/18/linq-groupby-grouplist-uniquesort-mapping/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 17:49:55 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/09/18/linq-groupby-grouplist-uniquesort-mapping/</guid>
		<description><![CDATA[I’ve done a bunch of Lat/Long type mapping programs over the years and one of the problems always ends up around performance.&#160; A common problem is that you keep redrawing the same line over and over and over.&#160; The pixels you are drawing don’t get any darker so all you are doing is wasting time.&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve done a bunch of Lat/Long type mapping programs over the years and one of the problems always ends up around performance.&#160; A common problem is that you keep redrawing the same line over and over and over.&#160; The pixels you are drawing don’t get any darker so all you are doing is wasting time.&#160; In my current project, we were drawing approximately 1500 lines when we really only had about 150 unique lines.&#160; I’ve always known how to solve this problem with a bunch of thrown together hacked up code, but now, <a href="http://www.hookedonlinq.com/LinqToSQL5MinuteOVerview.ashx">LINQ</a> gives me a very clean way to do it.</p>  <p>So, the problem is you have a record that looks like this:</p>  <pre class="csharpcode"> <span class="kwrd">public</span> <span class="kwrd">class</span> LoadSegmentInfoFlat
        {
            <span class="kwrd">public</span> <span class="kwrd">double</span>? OriginLattitude { get; set; }
            <span class="kwrd">public</span> <span class="kwrd">double</span>? OriginLongitude { get; set; }
            <span class="kwrd">public</span> <span class="kwrd">double</span>? DestinationLattitude { get; set; }
            <span class="kwrd">public</span> <span class="kwrd">double</span>? DestinationLongitude { get; set; }
            <span class="kwrd">public</span> <span class="kwrd">string</span> Color { get; set; }
        }</pre>
<span id="more-357"></span>

<p>You’ve created a list of these and defined it as follows:</p>

<pre class="csharpcode">var loadSegmentInfoFlats = <span class="kwrd">new</span> List&lt;LoadController.LoadSegmentInfoFlat&gt;();</pre>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Now, you want to create a unique list of Lattitude, Longitude Origins and Destinations by color.</p>

<p>The LINQ query that does the trick is a simple group by that creates an anonymous result (which is our answer).&#160; Here is the LINQ query (thanks to my friend in the <a href="http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/3846fd8f-7616-4eb2-a024-7b5dda508a04">MSDN LINQ Forums</a>, Lignzhi Sun).</p>

<pre class="csharpcode">var segments = from a <span class="kwrd">in</span> loadSegmentInfoFlats
               group a by
                   <span class="kwrd">new</span>
                       {
                           a.OriginLattitude,
                           a.OriginLongitude,
                           a.DestinationLattitude,
                           a.DestinationLongitude,
                           a.Color
                       }
               into grouplist
                   select
                   <span class="kwrd">new</span>
                       {
                           grouplist.Key.OriginLattitude,
                           grouplist.Key.OriginLongitude,
                           grouplist.Key.DestinationLattitude,
                           grouplist.Key.DestinationLongitude,
                           grouplist.Key.Color,
                           Count = grouplist.Count()
                       };</pre>

<p>&#160;</p>

<p>The resulting segments in Visual Studio 2008 debugger are as follows:</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/SomeReallyCoolLINQtoHelpPerformanceandSh_931C/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/SomeReallyCoolLINQtoHelpPerformanceandSh_931C/image_thumb.png" width="492" height="321" /></a></p>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Hope this helps!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/09/18/linq-groupby-grouplist-uniquesort-mapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Disable Edit/Insert/New Buttons in DetailsView or GridView (ASP.NET 2.0+)</title>
		<link>http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/</link>
		<comments>http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 00:27:24 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[DetailsView]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/</guid>
		<description><![CDATA[So, this is kind of embarrassing, that it took me a while to figure this out.&#160; I have not been doing pure asp.net server control programming for a while, but I figure since it took me a while, maybe there is someone else in the same boat.  So, you have a GridView or DetailsView [...]]]></description>
			<content:encoded><![CDATA[<p>So, this is kind of embarrassing, that it took me a while to figure this out.&#160; I have not been doing pure asp.net server control programming for a while, but I figure since it took me a while, maybe there is someone else in the same boat.</p>  <p>So, you have a GridView or <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview(VS.80).aspx">DetailsView</a> that has standard “Edit” “Update” “New” type command buttons on them.&#160; The way they get there is by having the declaration something like this:</p> <span id="more-352"></span>  <pre class="csharpcode"> &lt;asp:DetailsView ID=<span class="str">&quot;DetailsView1&quot;</span> runat=<span class="str">&quot;server&quot;</span> Height=<span class="str">&quot;50px&quot;</span> Width=<span class="str">&quot;125px&quot;</span> 
            AllowPaging=<span class="str">&quot;True&quot;</span> AutoGenerateRows=<span class="str">&quot;False&quot;</span> DataKeyNames=<span class="str">&quot;Id&quot;</span> 
            DataSourceID=<span class="str">&quot;SqlDataSource1&quot;</span>&gt;
            &lt;Fields&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Id&quot;</span> HeaderText=<span class="str">&quot;Id&quot;</span> ReadOnly=<span class="str">&quot;True&quot;</span> 
                    SortExpression=<span class="str">&quot;Id&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Name&quot;</span> HeaderText=<span class="str">&quot;Name&quot;</span> SortExpression=<span class="str">&quot;Name&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampStartDate&quot;</span> HeaderText=<span class="str">&quot;CampStartDate&quot;</span> 
                    SortExpression=<span class="str">&quot;CampStartDate&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampEndDate&quot;</span> HeaderText=<span class="str">&quot;CampEndDate&quot;</span> 
                    SortExpression=<span class="str">&quot;CampEndDate&quot;</span> /&gt;
                &lt;asp:CommandField ShowEditButton=<span class="str">&quot;True&quot;</span> ShowInsertButton=<span class="str">&quot;True&quot;</span> /&gt;
            &lt;/Fields&gt;
&lt;/asp:DetailsView&gt;</pre>
<style type="text/css">



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>What you want is to say something like:</p>

<p>“I only want admin’s to be able to add new rows so&#160; want to hide the “new” button based on that”</p>

<p>So, first thing is to convert the field to a template from the following menu.&#160; You do this by using the little helper in the upper right hand corner of the detailsview (in design mode), chose Edit Fields, CommandField, then convert to template (as in the picture below).</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/HowtoDisableEditInsertNewButtonsinDeta.0_F26A/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/HowtoDisableEditInsertNewButtonsinDeta.0_F26A/image_thumb.png" width="521" height="299" /></a></p>

<p>Then, you will have something like this:</p>

<pre class="csharpcode"> &lt;asp:DetailsView ID=<span class="str">&quot;DetailsView1&quot;</span> runat=<span class="str">&quot;server&quot;</span> Height=<span class="str">&quot;50px&quot;</span> Width=<span class="str">&quot;125px&quot;</span> 
            AllowPaging=<span class="str">&quot;True&quot;</span> AutoGenerateRows=<span class="str">&quot;False&quot;</span> DataKeyNames=<span class="str">&quot;Id&quot;</span> 
            DataSourceID=<span class="str">&quot;SqlDataSource1&quot;</span>&gt;
            &lt;Fields&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Id&quot;</span> HeaderText=<span class="str">&quot;Id&quot;</span> ReadOnly=<span class="str">&quot;True&quot;</span> 
                    SortExpression=<span class="str">&quot;Id&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;Name&quot;</span> HeaderText=<span class="str">&quot;Name&quot;</span> SortExpression=<span class="str">&quot;Name&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampStartDate&quot;</span> HeaderText=<span class="str">&quot;CampStartDate&quot;</span> 
                    SortExpression=<span class="str">&quot;CampStartDate&quot;</span> /&gt;
                &lt;asp:BoundField DataField=<span class="str">&quot;CampEndDate&quot;</span> HeaderText=<span class="str">&quot;CampEndDate&quot;</span> 
                    SortExpression=<span class="str">&quot;CampEndDate&quot;</span> /&gt;
                &lt;asp:TemplateField ShowHeader=<span class="str">&quot;False&quot;</span>&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:LinkButton ID=<span class="str">&quot;LinkButton1&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span> 
                            CommandName=<span class="str">&quot;Edit&quot;</span> Text=<span class="str">&quot;Edit&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                        &amp;nbsp;&lt;asp:LinkButton ID=<span class="str">&quot;LinkButton2&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span> 
                            CommandName=<span class="str">&quot;New&quot;</span> Text=<span class="str">&quot;New&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                    &lt;/ItemTemplate&gt;
                    &lt;EditItemTemplate&gt;
                        &lt;asp:LinkButton ID=<span class="str">&quot;LinkButton1&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;True&quot;</span> 
                            CommandName=<span class="str">&quot;Update&quot;</span> Text=<span class="str">&quot;Update&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                        &amp;nbsp;&lt;asp:LinkButton ID=<span class="str">&quot;LinkButton2&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span> 
                            CommandName=<span class="str">&quot;Cancel&quot;</span> Text=<span class="str">&quot;Cancel&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                    &lt;/EditItemTemplate&gt;
                    &lt;InsertItemTemplate&gt;
                        &lt;asp:LinkButton ID=<span class="str">&quot;LinkButton1&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;True&quot;</span> 
                            CommandName=<span class="str">&quot;Insert&quot;</span> Text=<span class="str">&quot;Insert&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                        &amp;nbsp;&lt;asp:LinkButton ID=<span class="str">&quot;LinkButton2&quot;</span> runat=<span class="str">&quot;server&quot;</span> CausesValidation=<span class="str">&quot;False&quot;</span> 
                            CommandName=<span class="str">&quot;Cancel&quot;</span> Text=<span class="str">&quot;Cancel&quot;</span>&gt;&lt;/asp:LinkButton&gt;
                    &lt;/InsertItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
            &lt;/Fields&gt;
&lt;/asp:DetailsView&gt;</pre>

<p>
  <br /></p>
<style type="text/css">



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Now, you have standard &lt;asp:LinkButton&gt; so you can call the visible property from your codebehind like this:</p>

<pre class="csharpcode"> <span class="kwrd">&lt;</span><span class="html">asp:TemplateField</span> <span class="attr">ShowHeader</span><span class="kwrd">=&quot;False&quot;</span><span class="kwrd">&gt;</span>
                     <span class="kwrd">&lt;</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span>
                         <span class="kwrd">&lt;</span><span class="html">asp:LinkButton</span> <span class="attr">ID</span><span class="kwrd">=&quot;LinkButton1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">CausesValidation</span><span class="kwrd">=&quot;False&quot;</span> <span class="attr">Visible</span><span class="kwrd">='&lt;%# GetShowEditButton() %&gt;'</span>
                             <span class="attr">CommandName</span><span class="kwrd">=&quot;Edit&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;Edit&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:LinkButton</span><span class="kwrd">&gt;</span>
                         <span class="attr">&amp;nbsp;</span><span class="kwrd">&lt;</span><span class="html">asp:LinkButton</span> <span class="attr">ID</span><span class="kwrd">=&quot;LinkButton2&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">CausesValidation</span><span class="kwrd">=&quot;False&quot;</span> <span class="attr">Visible</span><span class="kwrd">='&lt;%# GetShowInsertButton() %&gt;'</span>
                             <span class="attr">CommandName</span><span class="kwrd">=&quot;New&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;New&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:LinkButton</span><span class="kwrd">&gt;</span>
                         <span class="attr">&amp;nbsp;</span><span class="kwrd">&lt;</span><span class="html">asp:LinkButton</span> <span class="attr">ID</span><span class="kwrd">=&quot;LinkButton3&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">CausesValidation</span><span class="kwrd">=&quot;False&quot;</span> 
                             <span class="attr">CommandName</span><span class="kwrd">=&quot;Delete&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;Delete&quot;</span> <span class="attr">Visible</span><span class="kwrd">='&lt;%# GetShowDeleteButton() %&gt;'</span>     <span class="kwrd">&gt;&lt;/</span><span class="html">asp:LinkButton</span><span class="kwrd">&gt;</span>
                     <span class="kwrd">&lt;/</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">asp:TemplateField</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Then, in your codebehind, you have the following:</p>

<pre class="csharpcode"> <span class="kwrd">protected</span> <span class="kwrd">bool</span> GetShowEditButton()
    {
        <span class="kwrd">return</span> Roles.IsUserInRole(<span class="str">&quot;Admin&quot;</span>);
    }

    <span class="kwrd">protected</span> <span class="kwrd">bool</span> GetShowInsertButton()
    {
        <span class="kwrd">return</span> Roles.IsUserInRole(<span class="str">&quot;Admin&quot;</span>);
    }
    <span class="kwrd">protected</span> <span class="kwrd">bool</span> GetShowDeleteButton()
    {
        <span class="kwrd">return</span> Roles.IsUserInRole(<span class="str">&quot;Admin&quot;</span>);
    }
}</pre>

<p>Hope you find this before spending a bunch of time reading about more complicated solutions.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/09/06/detailsview-gridview-aspnet-disable-new-edit-delete-buttons/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>A New Book on Using MSBuild and Team Foundation Server</title>
		<link>http://peterkellner.net/2009/02/12/msbuild-bookreview-tfs-visualstudio-microsoft/</link>
		<comments>http://peterkellner.net/2009/02/12/msbuild-bookreview-tfs-visualstudio-microsoft/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 19:03:41 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/02/12/msbuild-bookreview-tfs-visualstudio-microsoft/</guid>
		<description><![CDATA[&#160;  William Bartholomew just published a new book on MSBuild and TFS. There is a great forward by Richard Hundhausen (Famous TFS Author and top MS consultant).&#160; I personally don’t use TFS yet, but I do use MSBuild and plan on using it more extensively for web deployments going forward.&#160; I have not yet [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p><a href="http://blog.bartholomew.id.au/">William Bartholomew</a> just published a new book on MSBuild and <a href="http://en.wikipedia.org/wiki/Team_Foundation_Server">TFS</a>. There is a great forward by <a href="www.accentient.com">Richard Hundhausen</a> (Famous TFS Author and top MS consultant).&#160; I personally don’t use TFS yet, but I do use <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx">MSBuild</a> and plan on using it more extensively for web deployments going forward.&#160; I have not yet read the book, but am anxiously looking forward to.&#160; It is a topic that IMHO has been very under documented.&#160; This should be a big help!</p>  <div class="wlWriterEditableSmartContent" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:8b16b1b3-85f5-44c2-80ce-e8e85835c6db" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><table cellspacing="0" cellpadding="2" width="400" border="0" unselectable="on">
<tbody><tr>
<td valign="top" width="400">
<p><a title="Inside the Microsoft&reg; Build Engine: Using MSBuild and Team Foundation Build (PRO-Developer): Sayed Ibrahim Hashimi, William Bartholomew: Books" href="http://www.amazon.com/exec/obidos/ASIN/0735626286/petkelsblo-20"><img src="http://images.amazon.com/images/P/0735626286.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left">Inside the Microsoft&reg; Build Engine: Using MSBuild and Team Foundation Build (PRO-Developer): Sayed Ibrahim Hashimi, William Bartholomew: Books</a><br /><br /></p>
</td></tr></tbody></table></div>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/02/12/msbuild-bookreview-tfs-visualstudio-microsoft/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Experience with Visual Studio 2008 Database Edition, I love it!!!</title>
		<link>http://peterkellner.net/2009/01/17/visual-studio-database-edition-review-sqlserver2008/</link>
		<comments>http://peterkellner.net/2009/01/17/visual-studio-database-edition-review-sqlserver2008/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 22:06:11 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/01/17/visual-studio-database-edition-review-sqlserver2008/</guid>
		<description><![CDATA[As a developer who has spent much of my life doing DBA type work, I really appreciate the simplicity and elegance of what Microsoft Visual Studio Team has put together with the Database Edition and can be seen for sale here as the 

Microsoft Visual Studio 2010 Premium with MSDN Download &#8211; Download Direct from [...]]]></description>
			<content:encoded><![CDATA[<p>As a developer who has spent much of my life doing DBA type work, I really appreciate the simplicity and elegance of what <a href="http://msdn.microsoft.com/en-us/vsts2008/products/bb933747.aspx">Microsoft Visual Studio Team</a> has put together with the <a href="http://blogs.msdn.com/gertd/archive/2007/11/21/visual-studio-team-system-2008-database-edition.aspx">Database Edition</a> and can be seen for sale here as the 

<a href="http://click.linksynergy.com/fs-bin/click?id=cLhVEJVzoSE&#038;offerid=166833.737&#038;type=2&#038;subid=0">Microsoft Visual Studio 2010 Premium with MSDN Download &#8211; Download Direct from Microsoft</a><IMG border=0 width=1 height=1 src="http://ad.linksynergy.com/fs-bin/show?id=cLhVEJVzoSE&#038;bids=166833.737&#038;type=2&#038;subid=0" >

 I&#8217;ll first try and explain in a nutshell what it is.&#160; Then I&#8217;ll go through an example of creating a Visual Studio Database Project out of a site I&#8217;ve been working on to show the steps.&#160; Finally, I&#8217;ll give a short summary reliving the experience and giving you some other pointers that may help you get through the experience.</p>

<h3>What is VS2008 Database Edition?</h3>

<p>Basically, what VS2008 does is to first process your existing schema into hundreds (maybe thousands) of little files.&#160; That is, each file is one database thing. That thing might be a table definition, a stored procedure, a trigger, a constraint, a foreign key, etc.&#160; The beauty of this is that now, each thing can be tracked separately.&#160; Say for example, you want to update just one table and someone else on your team wants to update another table in the same schema.&#160; Since the files are now separate files, it&#8217;s no problem.&#160; When you grab the latest changes from source control, you will get your friends changes and he will get yours.&#160; Very very clean!</p>
<div id='extendedEntryBreak' name='extendedEntryBreak'></div>

<p>Also, it has a very powerful comparison engine.&#160; Say you update your data outside of this project.&#160; VS2008 Database Edition will compare your definitions in all these little files with either a sql script you generate, or it will connect to an external database and compare to that.&#160; Me personally, I like to use a tool called <a href="http://www.sqlmanager.net/en/products/studio/mssql">SqlManager</a> to manage my data.&#160; I can continue to do that, then when I&#8217;ve made my changes, I can simply connect VS2008 Database Edition to my updated development database and it will automatically figure out the changes.</p>

<p>So, you may ask, what version do I need to run this of Visual Studio?&#160; The answer is in this link:&#160; <a title="http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx" href="http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx">http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx</a></p>

<h3>Here We Go, Let&#8217;s do an Example</h3>

<p>So, first, I will open my existing solution which has a web project in it, a data access project as well as other projects.&#160; Then, I create the new Database solution by saying File/Open/New Project/Database Project.</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb.png" width="395" height="208" /></a></p>

<p>Then, we follow the wizard&#8230;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_3.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_3.png" width="244" height="182" /></a></p>

<p>Taking defaults&#8230;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_4.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_4.png" width="244" height="182" /></a></p>

<p><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_5.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_5.png" width="244" height="182" /></a></p>

<p>Now, I choose my schema.</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_6.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_6.png" width="244" height="182" /></a></p>

<p>Press Start&#8230;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_7.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_7.png" width="244" height="182" /></a></p>

<p>Once you&#8217;ve done that, you&#8217;ll now have your schema spread out across your project in little files.&#160; Below is what the &quot;file based&quot; view of your schema looks like.</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_8.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_8.png" width="412" height="295" /></a></p>

<p>Notice that the file we are looking at also includes comments for both the table and the columns using the standard extended property documentation format as follows:</p>

<pre class="csharpcode"><span class="kwrd">GO</span>
<span class="kwrd">EXECUTE</span> sp_addextendedproperty @name = N<span class="str">'MS_Description'</span>, 
@<span class="kwrd">value</span> = N<span class="str">'tracks all changes from each camp

title;link;guid;pubDate;category;description'</span>, @level0type = N<span class="str">'SCHEMA'</span>, 
@level0name = N<span class="str">'dbo'</span>, @level1type = N<span class="str">'TABLE'</span>, 
@level1name = N<span class="str">'CampFeed'</span>;


<span class="kwrd">GO</span>
<span class="kwrd">EXECUTE</span> sp_addextendedproperty @name = N<span class="str">'MS_Description'</span>, 
@<span class="kwrd">value</span> = N<span class="str">'if true, this is the main news feed from the site.  
there should only be one main news feed from any site.  this would 
not be feeds like twitter'</span>, @level0type = N<span class="str">'SCHEMA'</span>, 
@level0name = N<span class="str">'dbo'</span>, 
@level1type = N<span class="str">'TABLE'</span>, @level1name = N<span class="str">'CampFeed'</span>, 
@level2type = N<span class="str">'COLUMN'</span>, @level2name = N<span class="str">'PrimaryFeed'</span>;</pre>

<pre class="csharpcode">&#160;</pre>

<pre class="csharpcode">Now, when you actually build the project as follows:</pre>

<pre class="csharpcode"><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_9.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_9.png" width="242" height="244" /></a> </pre>

<p>it will generate the full script combining all the files back into one again. Here is where it puts it:</p>

<pre class="csharpcode">&#160;</pre>

<pre class="csharpcode"><a href="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_10.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/FirstExperiencewithVisualStudio2008Datab_A011/image_thumb_10.png" width="414" height="332" /></a> </pre>

<pre class="csharpcode">&#160;</pre>

<p>So, that&#8217;s about it for now. I haven&#8217;t gone into any of the ways to compare and update your schema based on external changes, but we can leave that for another post.</p>

<p>To see a great video by <a href="http://blog.hundhausen.com/">Richard Hundhausen</a>, President of <a title="http://www.accentient.com/" href="http://www.accentient.com/">Accentient</a>, a <a href="http://msdn.microsoft.com/en-us/vsts2008/aa718934.aspx">Team Systems</a> Consulting company, go to this link:&#160; <a title="http://msdn.microsoft.com/en-us/vsts2008/cc659682.aspx" href="http://msdn.microsoft.com/en-us/vsts2008/cc659682.aspx">http://msdn.microsoft.com/en-us/vsts2008/cc659682.aspx</a></p>

<p>Also, if you are using Sql Server 2008, make sure you install visual studio 2008 sp1, then go to this link and install the download:&#160; <a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;displaylang=en</a></p>

<h3>Conclusions</h3>

<p>From what I can tell, this Visual Studio Database Edition will be a huge help in building database schema&#8217;s and database programs (sp&#8217;s, triggers,etc.) in a collaborative environment.&#160;&#160; If you have the license to use this, I strongly recommend it.&#160; It is definitely going to be part of my tool kit for now on.&#160; Even if I&#8217;m the only author in the project.</p>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/01/17/visual-studio-database-edition-review-sqlserver2008/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Logging your Sql with LINQ Update Commands. Simple Logging to your Visual Studio 2008 Debugger Output Console</title>
		<link>http://peterkellner.net/2008/12/04/linq-debug-output-vs2008/</link>
		<comments>http://peterkellner.net/2008/12/04/linq-debug-output-vs2008/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 02:13:34 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/12/04/linq-debug-output-vs2008/</guid>
		<description><![CDATA[ So, you want to do an update but are wondering what the hec LINQ is doing.&#160; Turns out it is really easy.&#160; All you have to do is run in the debugger and add the Log option to your data context.  Here is an example:     DataClassesGeneralDataContext db3pLogicContext;

  db3pLogicContext.Log [...]]]></description>
			<content:encoded><![CDATA[<p> So, you want to do an update but are wondering what the hec LINQ is doing.&#160; Turns out it is really easy.&#160; All you have to do is run in the debugger and add the Log option to your data context.</p>  <p>Here is an example:</p>  <div class="csharpcode">   <pre class="alt">DataClassesGeneralDataContext db3pLogicContext;</pre>

  <pre>db3pLogicContext.Log = Console.Out;</pre>

  <pre class="alt">&#160;</pre>

  <pre>var companyQuery = from tbl <span class="kwrd">in</span> db3pLogicContext.Companies</pre>

  <pre class="alt">                   <span class="kwrd">where</span> tbl.ParentId != 0</pre>

  <pre>                   select tbl;</pre>

  <pre class="alt">&#160;</pre>

  <pre><span class="kwrd">int</span> totalCntParents = companyQuery.Count();</pre>

  <pre class="alt"><span class="kwrd">foreach</span> (DBAccess.Company co <span class="kwrd">in</span> companyQuery)</pre>

  <pre>{</pre>

  <pre class="alt">    co.CreateDate = DateTime.Now;</pre>

  <pre>    <span class="kwrd">break</span>;</pre>

  <pre class="alt">}</pre>

  <pre>&#160;</pre>

  <pre class="alt">db3pLogicContext.SubmitChanges();</pre>
</div>

<div class="csharpcode">&#160;</div>
<span id="more-192"></span>

<p>Now, when you run the code, you can look on your debugger output and see something that looks like this:</p>

<div class="csharpcode"><a href="http://peterkellner.net/blogimages/LoggingyourSqlwithLINQUpdateCommands_FEF2/image.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://peterkellner.net/blogimages/LoggingyourSqlwithLINQUpdateCommands_FEF2/image_thumb.png" width="431" height="417" /></a> </div>

<div class="csharpcode">&#160;</div>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Also, if you want to actually execute select type statements, take a look at the Query Visualizer posted on Scott Guthrie&#8217;s web site:</p>

<p><a title="http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx" href="http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx">http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx</a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/12/04/linq-debug-output-vs2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQPad is Totally Awesome at Testing and Writing LINQ Queries</title>
		<link>http://peterkellner.net/2008/09/20/linqpad-sqlserver-linq-interpreter-nutshell/</link>
		<comments>http://peterkellner.net/2008/09/20/linqpad-sqlserver-linq-interpreter-nutshell/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 02:25:56 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/09/20/linqpad-sqlserver-linq-interpreter-nutshell/</guid>
		<description><![CDATA[http://www.linqpad.net/ &#8211; Use with Microsoft .Net for building Query type expressions with LINQ  I&#8217;m not a wizard at writing LINQ expressions so I often find myself in Google looking for something similar to what I want, then I put it into my application and run it. This has worked pretty well, but it takes [...]]]></description>
			<content:encoded><![CDATA[<p><a title="http://www.linqpad.net/" href="http://www.linqpad.net/">http://www.linqpad.net/</a> &#8211; Use with Microsoft .Net for building Query type expressions with LINQ</p>  <p>I&#8217;m not a wizard at writing <a href="http://msdn.microsoft.com/en-us/netframework/aa904594.aspx">LINQ</a> expressions so I often find myself in <a href="http://google.com">Google</a> looking for something similar to what I want, then I put it into my application and run it. This has worked pretty well, but it takes a couple iterations to get it right. It occured to me that someone probably has written a LINQ interpreter so I just guessed the name, <a href="http://www.linqpad.net/">LINQPad</a>, typed it into search, and I find the authors of the book C# 3.0 in a nutshell, <a href="http://www.technosis.com.au/Training.aspx">Joseph Albahari</a> and <a href="http://www.oreillynet.com/pub/au/465">Ben Albahari</a>, (which I like a lot) have written it.</p> <span id="more-162"></span>  <p>I download it (it&#8217;s an exe file), run it (OK, I trust you guys somehow), and presto, I get a very nice interface that not only has tons of examples built into it with a nice tree view, but lets me make a connection to my database and run LINQ queries against it. It even cancels them when you create one that will run forever (very nice guys!).</p>  <p>So, the query I was going after is I have a huge list of cities that includes states. From that, I just want a unique list of states (this list does not have all the states so I want just the ones contained in it). Below is a screen shot of the <a href="http://www.linqpad.net/">LINQPad</a> with my Query in it. I simply pressed the green triangle (trained by <a href="http://msdn.microsoft.com/en-us/library/aa174466(SQL.80).aspx">Sql Server Enterprise Manager</a>), and presto, my list! Could not be much easier. This tool will be in my box for a long time.</p>  <p>&#160;</p>  <table border="0" cellspacing="0" cellpadding="5" width="400"><tbody>     <tr>       <td valign="top" width="200"><a href="http://www.peterkellner.net/FilesForWebDownload/LINQPadistotallyawesomeattestingandwriti_11132/image.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.peterkellner.net/FilesForWebDownload/LINQPadistotallyawesomeattestingandwriti_11132/image_thumb.png" width="436" height="462" /></a></td>        <td valign="top" width="200">         <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:f6c31e3c-c91c-488b-9956-0209b5fc625f" class="wlWriterSmartContent">           <table border="0" cellspacing="0" cellpadding="2" width="400"><tbody>               <tr>                 <td valign="top" width="400">                   <p><a title="Amazon.com: C# 3.0 in a Nutshell" href="http://www.amazon.com/exec/obidos/ASIN/0596527578/petkelsblo-20"><img border="0" align="left" src="http://images.amazon.com/images/P/0596527578.01.MZZZZZZZ.jpg" />Amazon.com: C# 3.0 in a Nutshell</a></p>                 </td>               </tr>             </tbody></table>         </div>       </td>     </tr>   </tbody></table>  <p>&#160;</p>  <p>Grab this now!&#160; It&#8217;s a winner, believe me.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/09/20/linqpad-sqlserver-linq-interpreter-nutshell/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How to find your temporary asp.net executing assemblies location</title>
		<link>http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/</link>
		<comments>http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 19:22:46 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/</guid>
		<description><![CDATA[Seems, I keep forgetting where the temporary files asp.net uses. The reason it&#8217;s nice to know is sometimes you may want to open them with Reflector to see the generated code.&#160; Also, sometimes, you want to delete those files because asp.net is confused and is reusing old ones.&#160; So, here is the magic lines of [...]]]></description>
			<content:encoded><![CDATA[<p>Seems, I keep forgetting where the temporary files <a href="http://www.asp.net/">asp.net</a> uses. The reason it&#8217;s nice to know is sometimes you may want to open them with <a href="http://www.aisto.com/roeder/dotnet/">Reflector</a> to see the generated code.&#160; Also, sometimes, you want to delete those files because asp.net is confused and is reusing old ones.&#160; So, here is the magic lines of code you need.</p> <span id="more-136"></span>  <div class="csharpcode">   <pre class="alt">&lt;%@ Page Language=<span class="str">&quot;C#&quot;</span> %&gt;</pre>

  <pre>&#160;</pre>

  <pre class="alt">&lt;!DOCTYPE html PUBLIC <span class="str">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span class="str">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</pre>

  <pre>&#160;</pre>

  <pre class="alt">&lt;script runat=<span class="str">&quot;server&quot;</span>&gt;</pre>

  <pre>&#160;</pre>

  <pre class="alt">    <span class="kwrd">protected</span> <span class="kwrd">void</span> Page_Load(<span class="kwrd">object</span> sender, EventArgs e)</pre>

  <pre>    {</pre>

  <pre class="alt">        LabelWhere.Text = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString();</pre>

  <pre>    }</pre>

  <pre class="alt">&lt;/script&gt;</pre>

  <pre>&#160;</pre>

  <pre class="alt">&lt;html xmlns=<span class="str">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</pre>

  <pre>&lt;head runat=<span class="str">&quot;server&quot;</span>&gt;</pre>

  <pre class="alt">    &lt;title&gt;&lt;/title&gt;</pre>

  <pre>&lt;/head&gt;</pre>

  <pre class="alt">&lt;body&gt;</pre>

  <pre>    &lt;form id=<span class="str">&quot;form1&quot;</span> runat=<span class="str">&quot;server&quot;</span>&gt;</pre>

  <pre class="alt">    &lt;div&gt;</pre>

  <pre>        &lt;asp:Label ID=<span class="str">&quot;LabelWhere&quot;</span> runat=<span class="str">&quot;server&quot;</span> Text=<span class="str">&quot;Label&quot;</span>&gt;&lt;/asp:Label&gt;</pre>

  <pre class="alt">    &lt;/div&gt;</pre>

  <pre>    &lt;/form&gt;</pre>

  <pre class="alt">&lt;/body&gt;</pre>

  <pre>&lt;/html&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Hope this Helps!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/08/18/find-temp-aspnet-assembly-executing-reflection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building High Performance ASP.NET Web Applications Downloads</title>
		<link>http://peterkellner.net/2008/06/29/build-high-performance_web-applications-downloads/</link>
		<comments>http://peterkellner.net/2008/06/29/build-high-performance_web-applications-downloads/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 20:44:21 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/06/29/build-high-performance_web-applications-downloads/</guid>
		<description><![CDATA[<br /><p>Downloads for my presentation to BAADD titled "Building High Performance ASP.NET Web Applications".</p><br />]]></description>
			<content:encoded><![CDATA[<p>This past Wednesday, June 25th 2008, I did a presentation titled &#8220;<a href="http://peterkellner.net/2008/06/17/speaking-microsoft-office-june-25-2008-high-perf-aspnet/">Building High Performance ASP.NET Web Applications</a>&#8221; to the <a href="http://www.baadd.org/NET/tabid/56/Default.aspx">Bay Area Association of Database Developers (BAADD)</a>.&nbsp; Through out the presentation, I showed an application in <a href="http://msdn.microsoft.com/en-us/vstudio/products/aa700831.aspx">Visual Studio 2008</a>.&nbsp; I&#8217;m including that project file here as well as the power point slides used in the demonstration.</p> <p> <div class="wlWriterSmartContent" id="scid:18d43e01-4549-4fde-8ca6-c7b4b7385fac:9de1aefe-7d0d-40e3-b35c-603413b65c45" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"><p>Download Solution &#8211; <a href="http://peterkellner.net/wp/wp-content/uploads/2008/06/heuristiccache2.zip">HeuristicCache.zip</a></p></div></p> <p>And the Power Point Presentation:</p> <p> <div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:dfb47607-6296-4d5c-8edf-cd4e933fca8f" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"><p> <a href="http://peterkellner.net/wp/wp-content/uploads/2008/06/ppwebhigh2.pdf" target="_blank">Power Point Presentation</a></p></div></p> <p>Any Questions, feel free to contact me at <a title="http://peterkellner.net/contact/" href="http://peterkellner.net/contact/">http://peterkellner.net/contact/</a></p> <p><u><font color="#669966"></font></u></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/06/29/build-high-performance_web-applications-downloads/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Multi Level ASP.NET Menu with CSS Friendly Control AdaptersBuilding the New Code Camp Web Site (Part 2)</title>
		<link>http://peterkellner.net/2008/05/19/codecampwebsiteseries2/</link>
		<comments>http://peterkellner.net/2008/05/19/codecampwebsiteseries2/#comments</comments>
		<pubDate>Mon, 19 May 2008 22:38:46 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS Adapters]]></category>
		<category><![CDATA[Code Camp Web Site Series]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/05/19/codecampwebsiteseries2/</guid>
		<description><![CDATA[<p>This article discusses the CSS Friendly Adapters and how they are integraged with the ASP.NET 2.0 menu control.  It shows the default html created by a sample menu control without the Friendly Adapters, as well as showing the html created using the Friendly Adapters.</p>]]></description>
			<content:encoded><![CDATA[<h2>Article Series</h2>

<blockquote>
  <p><strong><em>(Source Code Available in Article 6 Below &#8211; (Added March 2009))</em></strong></p>
</blockquote>

<table border="0" cellspacing="0" cellpadding="2"><tbody>
    <tr>
      <td valign="top" width="100">Article 1:</td>

      <td valign="top" width="600"><a href="/2008/05/13/codecampwebsiteseries1/" target="_blank">Best Practices for Building an ASP.NET quality web site</a></td>
    </tr>

    <tr>
      <td>Article 2:</td>

      <td><a href="/2008/05/19/codecampwebsiteseries2/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters</a></td>
    </tr>

    <tr>
      <td>Article 3:</td>

      <td><a href="/2008/05/25/codecampwebsiteseries3/">Creating a Theme For Each Year of Code Camp Using Skins in ASP.NET</a></td>
    </tr>

    <tr>
      <td>Article 4:</td>

      <td><a href="/2008/06/29/sv-code-camp-web-site-series4/">Creating a Modal Login Window Using the Telerik Modal RadWindow Component</a></td>
    </tr>

    <tr>
      <td>Article 5:</td>

      <td><a href="/2008/07/03/combine-email-lists-with-linq/">Using LINQ to Merge Mailing Lists and Filter Opt Outs</a></td>
    </tr>

    <tr>
      <td>Article 6:</td>

      <td><a href="/2009/03/27/codecampwebsiteseries6-cssfriendly-adapters-aspnet-menu/">Multi Level ASP.NET Menu with CSS Friendly Control Adapters (The Source Code!)</a></td>
    </tr>
  </tbody></table>

<br />

<h2>Introduction</h2>

<div>
  <div class="peterkellnerpromo">If you have complex styling issues involving ASP.NET we are experts and might be able to help.  This technique is fairly old however newer methods could be used for similar results. Contact Peter Kellner and his associates <a href="http://peterkellner.net/contactus">here</a>. </div>

  <div>
    <p>It&#8217;s often the case that brilliant designers will make interfaces that are hard to implement using standard frameworks like ASP.NET.&#160; As Software engineers striving for consistency, we always want to do the best we can with the standard tool kits to take advantage for built in functionality.&#160; <a href="http://asp.net/" target="_blank">ASP.NET 2.0&#8217;s</a> built in menu system is a perfect example.&#160; If you use that menu system, you get to make very simple declarative site maps by simply using the <a href="http://weblogs.asp.net/scottgu/archive/2005/11/20/431019.aspx">ASP.NET 2.0 Site Navigation Features.</a></p>

    <p>The requirement faced today has to do with building the web site for our <a href="http://www.siliconvalley-codecamp.com/" target="_blank">third annual code camp</a>.&#160; We have that brilliant designer I mentioned above, and he has made a design that just seems too perfect to compromise.&#160; Here are some screen shots of how the designer envisions the sight looking and working after it is completed.</p>
  </div>

  
<span id="more-112"></span>


  <table border="0" cellspacing="0" cellpadding="2" width="800"><tbody>
      <tr>
        <td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css1.jpg">
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css1" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css1-thumb.jpg" width="740" height="133" /></a> 

          <br /></td>
      </tr>

      <tr>
        <td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css2.jpg">
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css2" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css2-thumb.jpg" width="741" height="121" /></a> 

          <br /></td>
      </tr>

      <tr>
        <td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css3.jpg">
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css3" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css3-thumb.jpg" width="740" height="136" /></a> 

          <br /></td>
      </tr>

      <tr>
        <td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css4.jpg">
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css4" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css4-thumb.jpg" width="741" height="124" /></a> 

          <br /></td>
      </tr>

      <tr>
        <td valign="top" width="800">
          <br /><a href="http://peterkellner.net/wp/wp-content/uploads/2008/05/css5.jpg">
            <br /><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="css5" src="http://peterkellner.net/wp/wp-content/uploads/2008/05/css5-thumb.jpg" width="748" height="134" /></a> 

          <br /></td>
      </tr>
    </tbody></table>

  <p>Notice the interesting behavior of the top menu (REGISTER;PROGRAM;NEWS;ABOUT AND WIKI).&#160; Unselected, the bottom line strip is the same as selected.&#160; When selected, the background of the selection changes to a different shade of the same color as the bottom strip.</p>

  <p>Also notice the interesting behavior of the secondary menu. that is, when ABOUT is selected from the top menu, notice that the secondary menu shows: Contact;Venue;Organizers;Sponsors and Previous.&#160; As you can see above (on the bottom of the 5 pictures), when Venu is selected, it is highlighted to in bright white to indicate that you have selected that.&#160; The really cool part here is that the ABOUT on the primary menu stays highlighted when you choose different&#160; secondary menu choices.</p>

  <h2>Why Go Through The Trouble, why not just do it with HTML and CSS directly</h2>

  <p>So, a reasonable person might say that since you can&#8217;t easily get this behavior with the asp:menu control and the site map provider (OK, at least I couldn&#8217;t figure it out), why not just code this up with simple list items, button clicks and a pile of code to react to those things?&#160; Well, the answer is you can certainly do that.&#160; The problem is the next time you want to do something similar you will find yourself doing a lot of cut and pasting.&#160; Personally, whenever I find myself cutting and pasting a lot I know I should probably think about how to refactor the code to make it more reusable and therefore more reliable.</p>

  <h2>What Are the Benefits of Using asp:menu and the site map providers </h2>

  <p>I mentioned that there are benefits to using the asp:menu and site map providers.&#160; What are those benefits you might ask.&#160; Well, let me first show you what you have to do to set up a simple menu system using these, then list the benefits of what comes out.</p>

  <h3>The Web.SiteMap</h3>

  <p>First, you need to create a web.sitemap file in your web directory.&#160; Here is what a simple one looks like similar to what will create the pictures above.</p>

  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">encoding</span><span class="kwrd">=&quot;utf-8&quot;</span> ?<span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>   <span class="kwrd">&lt;</span><span class="html">siteMap</span> <span class="attr">xmlns</span><span class="kwrd">=&quot;http://schemas.microsoft.com/AspNet/SiteMap-File-1.0&quot;</span> <span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">      <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Default.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;HOME&quot;</span> <span class="attr">description</span><span class="kwrd">=&quot;Silicon Valley CodeCamp 08&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Register.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;REGISTER&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;News.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;NEWS&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;About.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;ABOUT&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Contact.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;Contact&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Sponsors.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;Sponsors&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;</span><span class="html">siteMapNode</span> <span class="attr">url</span><span class="kwrd">=&quot;Previous.aspx&quot;</span> <span class="attr">title</span><span class="kwrd">=&quot;Previous&quot;</span>  <span class="attr">description</span><span class="kwrd">=&quot;&quot;</span> <span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre>         <span class="kwrd">&lt;/</span><span class="html">siteMapNode</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">      <span class="kwrd">&lt;/</span><span class="html">siteMapNode</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>   <span class="kwrd">&lt;/</span><span class="html">siteMap</span><span class="kwrd">&gt;</span></pre>
  </div>

  <h3>The Web.Config </h3>

  <p>You need to declare which sitemap provider you are using. In our case, we are simply reading from a file.&#160; Then, you should (do not have to) declare a section for each web page you want to provide role access to.&#160; Here is an example of my web.config. This first part says give access to any logged in user for Sponsors.aspx</p>

  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">&lt;</span><span class="html">location</span> <span class="attr">path</span><span class="kwrd">=&quot;Sponsors.aspx&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;</span><span class="html">system.web</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">        <span class="kwrd">&lt;</span><span class="html">authorization</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;</span><span class="html">deny</span> <span class="attr">users</span><span class="kwrd">=&quot;?&quot;</span><span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">        <span class="kwrd">&lt;/</span><span class="html">authorization</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;/</span><span class="html">system.web</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt"><span class="kwrd">&lt;/</span><span class="html">location</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre><span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre>
  </div>

  <p>The Second part defines the Site Map Provider and sets securityTrimming to true to only show pages the user has access to.</p>

  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">&lt;</span><span class="html">system.web</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;</span><span class="html">siteMap</span> <span class="attr">defaultProvider</span><span class="kwrd">=&quot;XmlSiteMapProvider&quot;</span> <span class="attr">enabled</span><span class="kwrd">=&quot;true&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">providers</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>        <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;XmlSiteMapProvider&quot;</span> </pre>

    <p>&#160;</p>

    <pre class="alt">        <span class="attr">description</span><span class="kwrd">=&quot;SiteMap provider which reads in .sitemap XML files.&quot;</span> </pre>

    <p>&#160;</p>

    <pre>        <span class="attr">type</span><span class="kwrd">=&quot;System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0,... </pre>

    <p>&#160;</p>

    <pre class="alt">        siteMapFile=&quot;</span><span class="attr">web</span>.<span class="attr">sitemap</span><span class="kwrd">&quot; securityTrimmingEnabled=&quot;</span><span class="attr">true</span>&quot;<span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;/</span><span class="html">providers</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">    <span class="kwrd">&lt;/</span><span class="html">siteMap</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>&#160;</pre>
  </div>

  <h3>The Master Page</h3>

  <p>In your master page, you need to define your primary menu.&#160; In our case, it is the one that displays: REGISTER;NEWS and ABOUT.&#160; Here is all you need for that.</p>

  <div class="csharpcode">
    <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">asp:Menu</span> <span class="attr">ID</span><span class="kwrd">=&quot;mainMenu&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">Orientation</span><span class="kwrd">=&quot;Horizontal&quot;</span> </pre>

    <p>&#160;</p>

    <pre>        <span class="attr">DataSourceID</span><span class="kwrd">=&quot;SiteMapMain&quot;</span> <span class="attr">CssClass</span><span class="kwrd">=&quot;headLinksBar&quot;</span>  <span class="attr">CssSelectorClass</span><span class="kwrd">=&quot;SimpleEntertainmentMenu&quot;</span></pre>

    <p>&#160;</p>

    <pre class="alt">        <span class="attr">MaximumDynamicDisplayLevels</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">StaticItemFormatString</span><span class="kwrd">=&quot;// {0} &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;/</span><span class="html">asp:Menu</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt"><span class="kwrd">&lt;</span><span class="html">asp:SiteMapDataSource</span> <span class="attr">ID</span><span class="kwrd">=&quot;SiteMapMain&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">ShowStartingNode</span><span class="kwrd">=&quot;False&quot;</span> <span class="kwrd">/&gt;</span></pre>
  </div>

  <h3>The Inherited Page (About.aspx For Example)</h3>

  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">&lt;</span><span class="html">asp:Content</span> <span class="attr">ID</span><span class="kwrd">=&quot;SublinksSessions&quot;</span> <span class="attr">ContentPlaceHolderID</span><span class="kwrd">=&quot;Sublinks&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;</span><span class="html">asp:Menu</span> <span class="attr">ID</span><span class="kwrd">=&quot;subMenu&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">DataSourceID</span><span class="kwrd">=&quot;SiteMapAbout&quot;</span> <span class="attr">SkinID</span><span class="kwrd">=&quot;subMenu&quot;</span>  <span class="attr">CssClass</span><span class="kwrd">=&quot;headLinksBar&quot;</span> </pre>

    <p>&#160;</p>

    <pre class="alt">    <span class="attr">CssSelectorClass</span><span class="kwrd">=&quot;SimpleEntertainmentMenu&quot;</span>     <span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;/</span><span class="html">asp:Menu</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt"><span class="kwrd">&lt;/</span><span class="html">asp:Content</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>&#160;</pre>
  </div>

  <h3>And the Benefits&#8230;</h3>

  <ul>
    <li>You have no .net code to write! </li>

    <li>Adding new menu items as Primary or Secondary is easy </li>

    <li>Security is completely taken care of </li>

    <li>Menu Entries Automatically come and go based on User Permission&#160; </li>
  </ul>

  <h2>Not Using the <a href="http://www.codeplex.com/cssfriendly" target="_blank">
      <p>CSS Friendly Adapters</p>
    </a></h2>

  <p>If you do not use the CSS Friendly Adapter library, the menu render using tables.&#160; <br />Below is what the actual HTML looks like of the main menu if I remove the</p>

  <p><a href="http://www.codeplex.com/cssfriendly" target="_blank">CSS Friendly Adapters</a>.</p>

  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">&lt;</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;#ctl00_mainMenu_SkipLink&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">        <span class="kwrd">&lt;</span><span class="html">img</span> <span class="attr">alt</span><span class="kwrd">=&quot;Skip Navigation Links&quot;</span> <span class="attr">src</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/WebResource.axd?d=G5&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">height</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">style</span><span class="kwrd">=&quot;border-width: 0px;&quot;</span> <span class="kwrd">/&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenu&quot;</span> <span class="attr">class</span><span class="kwrd">=&quot;headLinksBar ctl00_mainMenu_2&quot;</span> <span class="attr">cssselectorclass</span><span class="kwrd">=&quot;SimpleEntertainmentMenu&quot;</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>        <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">onmouseover</span><span class="kwrd">=&quot;Menu_HoverStatic(this)&quot;</span> <span class="attr">onmouseout</span><span class="kwrd">=&quot;Menu_Unhover(this)&quot;</span> <span class="attr">onkeyup</span><span class="kwrd">=&quot;Menu_Key(this)&quot;</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenun0&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                        <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;white-space: nowrap;&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                            <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">class</span><span class="kwrd">=&quot;ctl00_mainMenu_1&quot;</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/Register.aspx&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                                // REGISTER</pre>

    <p>&#160;</p>

    <pre class="alt">                            <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                        <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                    <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;width: 3px;&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">onmouseover</span><span class="kwrd">=&quot;Menu_HoverStatic(this)&quot;</span> <span class="attr">onmouseout</span><span class="kwrd">=&quot;Menu_Unhover(this)&quot;</span> <span class="attr">onkeyup</span><span class="kwrd">=&quot;Menu_Key(this)&quot;</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenun1&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;white-space: nowrap;&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                        <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">class</span><span class="kwrd">=&quot;ctl00_mainMenu_1&quot;</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/News.aspx&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                            // NEWS </pre>

    <p>&#160;</p>

    <pre>                        <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                    <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;width: 3px;&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">onmouseover</span><span class="kwrd">=&quot;Menu_HoverStatic(this)&quot;</span> <span class="attr">onmouseout</span><span class="kwrd">=&quot;Menu_Unhover(this)&quot;</span> <span class="attr">onkeyup</span><span class="kwrd">=&quot;Menu_Key(this)&quot;</span> <span class="attr">id</span><span class="kwrd">=&quot;ctl00_mainMenun2&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                        <span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">style</span><span class="kwrd">=&quot;white-space: nowrap;&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                            <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">class</span><span class="kwrd">=&quot;ctl00_mainMenu_1&quot;</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly%20-%20Copy/About.aspx&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                                // ABOUT</pre>

    <p>&#160;</p>

    <pre class="alt">                            <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                        <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                    <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;/</span><span class="html">span</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">        <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre><span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
  </div>

  <p>The same code, when using the <a href="http://www.codeplex.com/cssfriendly" target="_blank">CSS Friendly adapters</a>, plus some clever additions that will be discussed later, has the html code looking like the following.</p>

  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">&lt;</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>    <span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">        <span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-Horizontal&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>            <span class="kwrd">&lt;</span><span class="html">ul</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                <span class="kwrd">&lt;</span><span class="html">li</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-TopLevel-register&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly - Copy/Register.aspx&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                      REGISTER</pre>

    <p>&#160;</p>

    <pre>                     <span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span> </pre>

    <p>&#160;</p>

    <pre class="alt">                <span class="kwrd">&lt;/</span><span class="html">li</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                 <span class="kwrd">&lt;</span><span class="html">li</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-TopLevel-news&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly - Copy/News.aspx&quot;</span><span class="kwrd">&gt;</span>NEWS<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;/</span><span class="html">li</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                <span class="kwrd">&lt;</span><span class="html">li</span> <span class="attr">class</span><span class="kwrd">=&quot;AspNet-Menu-TopLevel-about-Selected&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">=&quot;/WebStyleOnly - Copy/About.aspx&quot;</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">                      ABOUT<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>                <span class="kwrd">&lt;/</span><span class="html">li</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">            <span class="kwrd">&lt;/</span><span class="html">ul</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre>         <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre class="alt">     <span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span></pre>

    <p>&#160;</p>

    <pre> <span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span></pre>
  </div>

  <p>You can see that the CSS adapter code is not only much smaller, but easier to read and because of the inserted class names, much easier to customize.</p>

  <h2>Conclusions</h2>

  <p>We have not made clear yet how the CSS Friendly Adapters will make the menu&#8217;s work the way we want it to. We have shown css classes created (AspNet-Menu-TopLevel-about-Selected for example) are create by the custom code written by us in the CSS Friendly Adapter Project.&#160; We have however talked about the menu control and showed an example of how the html is actually rendered, and what is rendered based on.&#160; That is, the web.sitemap defines the menu and we have shown that.&#160; In the next article, we will show details of the custom code we have in the CSS Friendly Adapter that solves the problem of how to highlight the menu choices based on what is clicked.</p>

  
</div>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/05/19/codecampwebsiteseries2/feed/</wfw:commentRss>
		<slash:comments>83</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 10/17 queries in 0.010 seconds using disk

Served from: peterkellner.net @ 2012-02-10 04:31:35 -->
