<?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>Jamie Dixon &#187; Visual Studio</title>
	<atom:link href="http://www.jamie-dixon.co.uk/category/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jamie-dixon.co.uk</link>
	<description>Web Developer, Software Engineer and Mixed Language Artist</description>
	<lastBuildDate>Thu, 18 Aug 2011 09:31:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Visual Studio &#8211; Lost nesting of codebehind</title>
		<link>http://www.jamie-dixon.co.uk/visual-studio/visual-studio-lost-nesting-of-codebehind/</link>
		<comments>http://www.jamie-dixon.co.uk/visual-studio/visual-studio-lost-nesting-of-codebehind/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 15:13:47 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[csproj]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.jamie-dixon.co.uk/?p=219</guid>
		<description><![CDATA[We&#8217;ve all had times when we&#8217;ve created an ASP.NET webpage and then a new page is required with almost identical functionality.
I had that task today and so making things simple I copied the current files, pasted them and made the necessary changes to hook the designer and code-behind files to the aspx page.
This works perfectly. [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all had times when we&#8217;ve created an ASP.NET webpage and then a new page is required with almost identical functionality.</p>
<p>I had that task today and so making things simple I copied the current files, pasted them and made the necessary changes to hook the designer and code-behind files to the aspx page.</p>
<p>This works perfectly. The code builds, the page runs, everything happens as I expected it to.</p>
<p>Then I noticed a little quirk in Visual Studio 2008. One of the great features of Visual Studio is the way in which it visually nests code-behind files in the Solution Explorer under your aspx file.</p>
<p>After making a copy of my origional page I noticed that my code-behind was left astray. I checked all the references to make sure everything was hooked up correctly but still, my code-behind wasn&#8217;t nesting nicely under my aspx page as usual.</p>
<p>Now I&#8217;m sure many people have come across this problem before however this was a first for me.</p>
<p>It turns out that the references are stores in the csproj file. There is a reference to the code-behind file and a list of dependancies. By default, when doing a copy/paste of files outside of Visual Studio, this reference is not updated and the code-behind file doesn&#8217;t attach itself to the aspx file in the Solution Explorer.</p>
<p>The solution is to simply add a reference to the dependant aspx fie in the csproj file like so:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p219code2'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2192"><td class="code" id="p219code2"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Compile</span> <span style="color: #000066;">Include</span>=<span style="color: #ff0000;">&quot;myShinyNewFile.aspx.cs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DependentUpon<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>myShinyNewFile.aspx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DependentUpon<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SubType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ASPXCodeBehind<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SubType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Compile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Once you&#8217;ve added the second line into the csproj file, restarting visual studio brings back the much loved nesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamie-dixon.co.uk/visual-studio/visual-studio-lost-nesting-of-codebehind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

