Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET code behind file not nested under the related aspx file in Visual Studio

In my C# ASP.NET Web Site using .NET Framework 4.0, I have a couple of pages where the related .cs file is not under its related aspx file. I recently moved the files to a subdirectory. I have 10 pages and for 8 of them the move worked just fine and the .cs file is under the aspx. However for two pages, the .cs file now no longer shows below the aspx file. How can I fix this so that the cs is shown correctly underneath the aspx file? When I compare the top of the markup pages, the two problem pages look just like the other 8 pages. I don't see any issues there.

like image 568
user31673 Avatar asked Dec 12 '22 12:12

user31673


1 Answers

First make sure they have the same name (except for the extension of course). If this does not help and it's a Web Application then try removing the 3 files (.aspx, .aspx.cs, aspx.designer.cs) from the project by right-click -> 'exclude from project'. Then add them again. The easiest way is to show all files (hint: screenshot), then right-click -> 'Include in project'.

VS 2010 Solution Explorer

like image 59
rciq Avatar answered May 12 '23 06:05

rciq