CS0103:名称“rGrid”当前上下文中不存在
我有一个 ASPX 页面:
<%@ Page Language="C#" MasterPageFile="~/site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myProject.Presentation.Web.Default" src="Default.aspx.cs" %>
<%@ MasterType VirtualPath="~/site.Master" %>
...
<asp:Repeater ID="rGrid" runat="server">
<ItemTemplate>
...
</ItemTemplate>
</asp:Repeater>
使用此 Master:
<%@ Master Language="C#" AutoEventWireup="true" Codebehind="site.master.cs" Inherits="myProject.Presentation.Web.master" src="~/site.Master.cs" %>
当我尝试访问该页面上的其中一个成员时:
namespace myProject.Presentation.Web {
public partial class Default : System.Web.UI.Page
...
rGrid.DataSource = myProject.Business.User.GetReports(UserId, true);
我在该行上得到此 YSOD:
CS0103: The name 'rGrid' does not exist in the current context
然而 Intellisense 和 Object Exporer 说它是有效的。这是为什么?
I have an ASPX Page:
<%@ Page Language="C#" MasterPageFile="~/site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myProject.Presentation.Web.Default" src="Default.aspx.cs" %>
<%@ MasterType VirtualPath="~/site.Master" %>
...
<asp:Repeater ID="rGrid" runat="server">
<ItemTemplate>
...
</ItemTemplate>
</asp:Repeater>
With this Master:
<%@ Master Language="C#" AutoEventWireup="true" Codebehind="site.master.cs" Inherits="myProject.Presentation.Web.master" src="~/site.Master.cs" %>
When I try to access one of the members on the page:
namespace myProject.Presentation.Web {
public partial class Default : System.Web.UI.Page
...
rGrid.DataSource = myProject.Business.User.GetReports(UserId, true);
I get this YSOD on that line:
CS0103: The name 'rGrid' does not exist in the current context
Yet Intellisense and Object Exporer say it's valid. Why is that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是网站还是网络应用程序?
如果它是 Web 应用程序,请删除您的设计器文件,然后右键单击您的 aspx 页面和/或母版页并选择转换为 Web 应用程序。这将重建设计器文件。
Is this a website or web app?
If it's a web app, delete your designer files, then right click on your aspx page and/or master page and select convert to web app. This will rebuild the designer files.
这是废话,把项目封装起来,重新做一个网站项目。
This is nonsense, canned the project and redoing it as a website project.
当变量减速和变量使用处于不同范围时,通常会出现此错误。检查 *.aspx.cs 文件和设计器文件命名空间,命名空间必须相同。
This error generally occurs when variable declerations and variable usage are in different scopes. Check *.aspx.cs file and designer file namespace , namespaces must be same..