asp.Net does not exist in current context

后端 未结 10 1800
夕颜
夕颜 2021-02-07 08:39

I am facing a small big problem. I have taken a dropdownList control and ID is \"drpDownCountries\" in ASP.Net project. The problem is that \"The dropdownlist contr

相关标签:
10条回答
  • 2021-02-07 09:20

    So first check that your ascx document is defined like so

    ExampleClass.ascx

        <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ExampleClass.ascx.cs" Inherits="ExampleClass" %>
    

    ExampleClass.ascx.cs

    public partial class ExampleClass : System.Web.UI.UserControl
    {
         protected void Page_Load(object sender, System.EventArgs e)
        {
    
        }
    }
    
    0 讨论(0)
  • 2021-02-07 09:24

    It's possible there is an error in your aspx/aspx file that is causing the designer file not to be updated correctly. You could confirm this by adding something new (eg. "") and see if you can access that. If not, something is probably broken in the markup that you'll need to fix.

    0 讨论(0)
  • 2021-02-07 09:29

    Right-click on the ASPX (or ascx) file, and select Convert to web application (or something like that). That will force a refresh on the designer file.

    0 讨论(0)
  • 2021-02-07 09:30

    The only thing that worked for me was to add a temp controller in the aspx file and saving it. That generated the designer again, and my controllers are now recognized! I'm so proud. You can then remove the temp controller and save, it won't ruin anything, you scaredy cat!

    0 讨论(0)
  • 2021-02-07 09:36

    Recreate the project. Just create a new project and add the elements one by one and hope it won't happen again. If it does, well that's part of the Microsoft experience: recreate another project and so on, until you decide to quit your job and join open-source.

    CORRECTION

    I'm going to redo the project that I have been working on since the last 3 days using ASP .NET MVC. I should be using an open-source tech for sure, but too bad it's not my decision for this project to not use .NET.

    0 讨论(0)
  • 2021-02-07 09:39

    In aspx this type of error often occurs when you miss runat="server"

    0 讨论(0)
提交回复
热议问题