In Visual Studio 2003 you can sometimes get this problem. May or may
not work the same in 2005, or there may be something similar, but after
adding all the files to the project, close down Visual Studio, then open
the project file in Notepad.
It'll have a whole load of:
<File
RelPath = "<Name of CS File>"
SubType = "Code"
BuildAction = "Compile"
/>
You want to change these to resemble:
<File
RelPath = "<Name of CS File>"
DependentUpon = "<Name of Aspx file>"
SubType = "ASPXCodeBehind"
BuildAction = "Compile"
/>
Easiest way to get format correct is to add a new page as you described,
then open the project file in notepad and find how the two files have
been added.
Damien,
Thanks for the reply, but I can't see this info anywhere. There is a
..sln file, but that doesn't contain anything like you suggested. The
only other project file I can see is a .suo file, which is binary.
Which file should I open? For interest, the .sln file contains...
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Web Developer Express 2005
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "C:\...\FirstTest\", "..\..\..\WebSites\FirstTest\", "{765AD130-A4CC-
4A92-BBD7-674C4E832F2E}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.VirtualPath = "/FirstTest"
Debug.AspNetCompiler.PhysicalPath = "..\..\..\WebSites\FirstTest\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\FirstTest\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "true"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/FirstTest"
Release.AspNetCompiler.PhysicalPath = "..\..\..\WebSites\FirstTest\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\FirstTest\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "true"
Release.AspNetCompiler.Debug = "False"
VWDPort = "1031"
DefaultWebSiteLanguage = "Visual C#"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{765AD130-A4CC-4A92-BBD7-674C4E832F2E}.Debug|.NET.ActiveCfg = Debug|.NET
{765AD130-A4CC-4A92-BBD7-674C4E832F2E}.Debug|.NET.Build.0 = Debug|.NET
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal