姓名并不在当前的背景下存在 [英] Name does not exist in the current context
问题描述
所以,我的工作我的笔记本电脑和桌面之间的项目。
So, I'm working on this project between my laptop and my desktop.
该项目工程在笔记本电脑上,但现在已经复制了更新的源$ C $ C到桌面上,我有超过500错误的项目,所有的人都...
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
}
下面是designer.cs文件的样本...
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?
推荐答案
Jobs.aspx
这是phyiscal文件 - > codeFILE =Jobs.aspx.cs
This is the phyiscal file -> CodeFile="Jobs.aspx.cs"
这是处理页面的事件类 - > 继承=Members_Jobs
This is the class which handles the events of the page -> Inherits="Members_Jobs"
Jobs.aspx.cs
这是在部分类管理页面事件 - > 公共部分类Members_Jobs:System.Web.UI.Page
This is the partial class which manages the page events -> public partial class Members_Jobs : System.Web.UI.Page
在部分类应的另一部分 - > 公共部分类Members_Jobs
这通常是设计文件
The other part of the partial class should be -> public partial class Members_Jobs
this is usually the designer file.
您不需要有部分类和可以宣布你的控件都在1级,而不是有一个设计师的文件。
you dont need to have partial classes and could declare your controls all in 1 class and not have a designer file.
修改 27/09/2013 11:37
EDIT 27/09/2013 11:37
如果您仍然有这个作为巴拉德瓦建议我会做,并删除设计器文件的问题。在页面上然后您可以单击鼠标右键,在解决方案资源管理器中,有一个选项,类似转换为Web应用程序,这将重新生成你的设计师文件
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
这篇关于姓名并不在当前的背景下存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!