Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Name does not exist in the current context

Tags:

c#

asp.net

So, I'm working on this project between my laptop and my desktop.

The project works on the laptop, but now having copied the updated source code onto the desktop, I have over 500 errors in the project, all of them are...

The name does not exist in the current context

Here's one example...

Jobs.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Members/Members.master" AutoEventWireup="true" CodeFile="Jobs.aspx.cs" Inherits="Members_Jobs" %>  <%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" TagPrefix="aj" %>  <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">     <asp:UpdatePanel runat="server" ID="upJobs">         <ContentTemplate>             <!-- page content goes here -->         </ContentTemplate>     </asp:UpdatePanel> </asp:Content> 

Jobs.aspx.cs

public partial class Members_Jobs : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {             loadJobs();             gvItems.Visible = false;             loadComplexes();             loadBusinesses();             loadSubcontractors();             loadInsurers();              pnlCallback.Visible = false;             pnlInsurer.Visible = false;         }     }      // more goes down here } 

Here's a sample of the designer.cs file...

namespace stman.Members {       public partial class Jobs {          /// <summary>         /// upJobs control.         /// </summary>         /// <remarks>         /// Auto-generated field.         /// To modify move field declaration from designer file to code-behind file.         /// </remarks>         protected global::System.Web.UI.UpdatePanel upJobs;     } } 

I know this error means that the control being referenced generally doesn't exist or is not a part of the class that's referencing it, but as far as I can see, that isn't the case here.

Can anyone provide some insight?

VS2012 Screenshot

like image 629
Ortund Avatar asked Sep 26 '13 11:09

Ortund


People also ask

How do I fix CS0103 error?

CS0103 is caused when you are using a name for a variable or method that does not exist within the context that you are using it. In order to fix the CS0103 error you will need to correct the name of the variable or method from where it is declared or referenced.


1 Answers

In case someone being a beginner who tried all of the above and still didn't 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.

like image 115
TheDanMan Avatar answered Sep 22 '22 08:09

TheDanMan