简体   繁体   English

错误CS0103:名称“ txtReferralCode”在当前上下文中不存在

[英]error CS0103: The name 'txtReferralCode' does not exist in the current context

I'm about ready to pull my hair out over this. 我正准备为此拉头发。 I'm working on an ASP.NET 2.0 website in VS2010 and I'm getting the error you see in the title. 我正在VS2010中的ASP.NET 2.0网站上工作,但出现标题中出现的错误。 The error only appears when I attempt to publish the website. 仅当我尝试发布网站时才会出现该错误。 If I simply right click the aspx file that it's in and click "View in Browser" it works perfectly fine. 如果我只是右键单击其中的aspx文件,然后单击“在浏览器中查看”,则可以正常工作。 It also works fine if I run the file in debug mode from VS2010. 如果我以VS2010的调试模式运行文件,它也可以正常工作。 There are other asp controls in the code that work perfectly fine, but for whatever reason, the one I've added has a problem. 代码中还有其他的asp控件可以很好地工作,但是无论出于什么原因,我添加的控件都有问题。

Here's some of the relevant code: 以下是一些相关代码:

c#: C#:

public partial class ApplicationScreen1Hold : System.Web.UI.Page
{
....
    protected void Page_Load(object sender, EventArgs e)
    {
    ....
         if (Request.QueryString["SID"] != null) //this is existing code
         {
             hdnSID.Value =  Request.QueryString["SID"].ToString().Trim();
          }
         if (Request.QueryString["RID"] != null) //this is my new code
         {
             txtReferralCode.Text = Request.QueryString["RID"];
         }
    ....
    }
}

html: 的HTML:

<td style="padding-left:25px">
    <label>Referral Code
         <asp:TextBox ID="txtReferralCode" runat="server" MaxLength="8"></asp:TextBox>
    </label>
</td>

In the c# code, I left in the line above to show how one of the other inputs in the same form is accessed with no issues. 在c#代码中,我在上面的行中显示了如何毫无问题地访问相同格式的其他输入之一。 The text box control in the html I had copies from another text box on the page and changed the id and removed the class and onkeyup event as they weren't needed. html中的文本框控件,我从页面上的另一个文本框复制了文本,并更改​​了id并删除了不需要的classonkeyup事件。

Is it possible I need to define the text box and I've just not found the where it does it for other controls or am I likely missing something else? 是否可能需要定义文本框,而我还没有找到它在其他控件中所处的位置,还是可能缺少其他内容?

I've looked at the other questions which have referenced this error code but none of them have been able to help me. 我查看了其他引用了此错误代码的问题,但是没有一个问题可以帮助我。

Delete designer file associated with your *.aspx file. 删除与您的* .aspx文件关联的设计器文件。 Right click *.aspx file and click "convert to web application". 右键单击* .aspx文件,然后单击“转换为Web应用程序”。 It will create a designer file thats *.aspx.designer.cs and this file must include all the controls you used in your .aspx file. 它将创建一个* .aspx.designer.cs设计器文件,并且该文件必须包含您在.aspx文件中使用的所有控件。 Make sure you use right namepsace thats *.aspx.designer.cs and *.aspx.cs controls are in the same namespace.. 确保使用正确的名称空间,即* .aspx.designer.cs和* .aspx.cs控件位于同一命名空间中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误 CS0103:当前上下文中不存在名称“_context” - Error CS0103: The name '_context' does not exist in the current context 错误CS0103:名称“ TimeSpan”在当前上下文(CS0103)(testingProgram)中不存在? - Error CS0103: The name 'TimeSpan' does not exist in the current context (CS0103) (testingProgram)? 错误 CS0103:当前上下文中不存在名称“currentScreen”(CS0103) - Error CS0103: The name 'currentScreen' does not exist in the current context (CS0103) 错误CS0103:名称“ DebugDisplayString”在当前上下文中不存在 - error CS0103: The name 'DebugDisplayString' does not exist in the current context 错误CS0103:名称“ ressourcesText”在当前上下文中不存在 - error CS0103: The name “ressourcesText” does not exist in the current context 错误 CS0103:当前上下文中不存在名称“playfabManager” - error CS0103: The name 'playfabManager' does not exist in the current context 错误cs0103名称&#39;IEnumerator&#39;在当前上下文中不存在 - error cs0103 The Name 'IEnumerator' does not exist in the current context 错误CS0103:名称“ HttpUtility”在当前上下文中不存在 - error CS0103: The name `HttpUtility' does not exist in the current context "错误 CS0103:当前上下文中不存在名称“AssetPreview”" - error CS0103: The name 'AssetPreview' does not exist in the current context 错误CS0103当前上下文中不存在名称“图像” - Error CS0103 The name 'Image' does not exist in the current context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM