【发布时间】:2015-11-08 00:10:54
【问题描述】:
我在 Xamarin IDE 上创建了新的 ASP.NET (C#) 项目。我的默认页面有一些 asp 控件,如标签、文本框和按钮。当我尝试从代码隐藏中访问它们时,我收到了这个错误:
error CS0103: The name xxxx does not exist in the current context.
这是我尝试访问它们的方式:
usernameTXT.Text = "John";
这是我的代码隐藏:
using System;
using System.Web;
using System.Web.UI;
using System.Collections.Generic;
using System.Web.UI.WebControls;
namespace advise
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
usernameTXT.Text = "John";
}
}
}
这是我在 aspx 页面中的控件的样子:
<asp:TextBox id="usernameTXT" runat="server" CssClass="control"></asp:TextBox>
值得一提的是,在xxx.aspx.designer.cs中没有生成任何东西:
using System;
using System.Web;
using System.Web.UI;
namespace advise
{
public partial class Default
{
}
}
请帮忙!我试图搜索这个问题没有任何帮助。这很奇怪,因为 Xamarin 为我做的代码隐藏自动与 Web 窗体相关联。
【问题讨论】:
-
是否“受保护的 System.Web.UI.WebControls.TextBox usernameTXT;”是否存在于自动生成的
XXXX.aspx.designer.cs文件中?如果没有,“重建所有”并再次检查。 -
XXXX.aspx.designer.cs 中实际上没有生成任何东西。
-
@RobertN 我做了“全部重建”但没有任何进展!
标签: c# asp.net webforms xamarin