ASP.NET Web Forms User control cannot find the code behind

Deivid Kirchev 95 Reputation points
2023-08-25T07:29:52.14+00:00

Greetings,

This has been going on for quite a bit now and I kind of got used to it but I would be grateful if someone can help me find an answer.

I have an asp.net webforms project with .ascx user controls. For some reason in the markup, it says it cannot find the code behind files meaning some autocompletes don't work and I can't go to the code behind using shortcuts (those are the things which I use the most). The project compiles and publishes without issues and everything works fine.

I have tried quite a bit of solutions online but nothing seemed to work. Last time I was able to fix it by recreating the project, but that is no longer an option as there are a lot of files now.

Thank you for your time!

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,417 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,888 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Albert Kallal 5,231 Reputation points
    2023-08-25T17:06:58.8333333+00:00

    Ok, this came up the other day here. And off and on for many years, I seen this issue.

    Now, I have trouble re-creating the issue!

    I suggest this:

    close all pages and code behind pages

    do a clean project.

    User's image

    Now, delete all files in the bin folder

    (ONLY do this assuming this is a asp.net web site application - one with .sln file).

    So, right click on the solution explorer, and choose open in file explore.

    eg:

    User's image

    browse to the bin folder and open it. Now, delete EVERYTHING inside. (so, ctrl-a, and then hit del key).

    Now, do a rebuild solution. This:

    User's image

    Now, try opening the aspx page with the ascx control. It should work.