Search code examples
c#asp.netvisual-studio-2005code-behind

The name 'controlname' does not exist in the current context


I have a web application that I'm working on (ASP.NET 2.0 with C#, using Visual Studio 2005). Everything was working fine, and all of a sudden I get the error:

Error 1 The name 'Label1' does not exist in the current context

and 43 others of the sort for each time that I used a control in my code behind page.

This is only happening for one page. And it's as if the code behind page isn't recognizing the controls. Another interesting thing is that the IntelliSense isn't picking up any of the controls either..

I have tried to clean the solution file, delete the obj file, exclude the files from the project then re-add them, close Visual Studio and restart it, and even restart my computer, but none of these have worked.


Solution

  • Check your code behind file name and Inherits property on the @Page directive, make sure they both match.