简体   繁体   English

调试 Visual Studio 代码中的 CS0103 错误

[英]Debugging CS0103 Error in Visual Studio code

Hi i am creating a dropdown list and inserting values programmatically from the code behind, however i am repeatedly getting the error CS0103.嗨,我正在创建一个下拉列表并以编程方式从后面的代码中插入值,但是我反复收到错误 CS0103。 However my program and web page is running completely fine, but it is just bothering me and was wondering if there exist a way to suppress those error messages or maybe i am missing something.但是我的程序和 web 页面运行完全正常,但这只是困扰我,想知道是否存在抑制这些错误消息的方法,或者我可能遗漏了什么。

Error: CS0103 The name 'ddlzip' does not exist in the current context错误:CS0103 当前上下文中不存在名称“ddlzip”

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace bse20bftmoviestore.tutorials.week3
{
    public partial class formSample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)//When page is loaded everytime
        {
  
            txtFname.Focus();
            
            if (!Page.IsPostBack)//When page is first loaded
            {
                //Code behind to create items in the dropdown
                ListItem li1 = new ListItem("Select zip code", "-1");
                ListItem li2 = new ListItem("1111", "1");
                ListItem li3 = new ListItem("2222", "2");
                ListItem li4 = new ListItem("3333", "3");
                ddlzip.Items.Add(li1);
                ddlzip.Items.Add(li2);
                ddlzip.Items.Add(li3);
                ddlzip.Items.Add(li4);

            }
        }
    }
}

My dropdown list in the web form:我在 web 表单中的下拉列表:

<!--zip code title and dropdown list (programmatically defined)-->
                <div class="form-group row justify-content-center">
                   <asp:Label runat="server" CssClass="col-md-2 col-form-label">Zip Code</asp:Label>
                      <div class="col-md-8">
                          <asp:DropDownList ID="ddlzip" CssClass="form-control" runat="server"></asp:DropDownList>
                      </div>
                </div>
<!--End of zip code title and dropdown list (programmatically defined)-->

Error: CS0103 The name 'ddlzip' does not exist in the current context错误:CS0103 当前上下文中不存在名称“ddlzip”

sometimes closing and then reopening the solution work.有时关闭然后重新打开解决方案工作。 the other solution is removing bin and obj folder and build project again.另一个解决方案是删除 bin 和 obj 文件夹并再次构建项目。 these solutions worked for me这些解决方案对我有用

The solution to this question is to link the both the CodeFile and CodeBehind in.aspx page title.这个问题的解决方案是链接 CodeFile 和 CodeBehind in.aspx 页面标题。

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

相关问题 在 Visual Studio 2019 中调试大多数变量时出现错误 CS0103 - Error CS0103 when debugging most variables in Visual Studio 2019 ASP.NET MVC 5和Visual Studio 2015RC CS0234和CS0103错误 - ASP.NET MVC 5 and Visual Studio 2015RC CS0234 and CS0103 errors ASP.NET中的错误CS0103 - error CS0103 in ASP.NET 错误CS0103 FastReport.net - Error CS0103 FastReport.net 使用源生成器时如何避免 Visual Studio 中出现 CS0103 错误? - How do I avoid CS0103 errors in Visual Studio when using Source Generators? 错误 CS0103:当前上下文中不存在名称“currentScreen”(CS0103) - Error CS0103: The name 'currentScreen' does not exist in the current context (CS0103) 错误CS0103:名称“ TimeSpan”在当前上下文(CS0103)(testingProgram)中不存在? - Error CS0103: The name 'TimeSpan' does not exist in the current context (CS0103) (testingProgram)? 错误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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM