c# – Name does not exist in the current context

c# – Name does not exist in the current context

In case someone being a beginner who tried all of the above and still didnt manage to get the project to work. Check your namespace. In an instance where you copy code from one project to another and you forget to change the namespace of the project then it will also give you this error.

Hope it helps someone.


This is the phyiscal file -> CodeFile=Jobs.aspx.cs

This is the class which handles the events of the page -> Inherits=Members_Jobs


This is the partial class which manages the page events -> public partial class Members_Jobs : System.Web.UI.Page

The other part of the partial class should be -> public partial class Members_Jobs this is usually the designer file.

you dont need to have partial classes and could declare your controls all in 1 class and not have a designer file.

EDIT 27/09/2013 11:37

if you are still having issues with this I would do as Bharadwaj suggested and delete the designer file. You can then right-click on the page, in the solution explorer, and there is an option, something like Convert to Web Application, which will regenerate your designer file

c# – Name does not exist in the current context

The project works on the laptop, but now having copied the updated source code onto the desktop …

I did something similar, creating two versions of a project and copying files between them. It gave me the same error.

My solution was to go into the project file, where I discovered that what had looked like this:

<Compile Include=App_CodeCommonPair.cs />
<Compile Include=App_CodeCommonQueryCommand.cs />

Now looked like this:

<Content Include=App_CodeCommonPair.cs>
<Content Include=App_CodeCommonQueryCommand.cs>

When I changed them back, Visual Studio was happy again.

Leave a Reply

Your email address will not be published.