ASP.NET controls cannot be referenced in code-behind in Visual Studio 2008

前端 未结 16 1321
面向向阳花
面向向阳花 2020-12-25 12:28

Ok, so, my visual studio is broken. I say this NOT prematurely, as it was my first response to see where I had messed up in my code. When I add controls to the page I can\'t

相关标签:
16条回答
  • 2020-12-25 12:34

    I observed this happens because of missing .designer.cs file. Following fixed this issue in my case (basically I had these files copied from VS 2005 web project to VS 2010 project): Right Click on .aspx file and select menu "Convert to Web site", this will create .designer.cs file and then it should work file.

    0 讨论(0)
  • 2020-12-25 12:35

    In my case new asp controls I added to an existing were not being detected.

    What worked for me was forcing a recompile by renaming an existing control to break the build eg: changing <asp:TextBox ID="txtTitle" runat="server" /> to <asp:TextBox ID="txtTitle2" runat="server" />

    When I corrected the ID and rebuilt a new designer file was generated with the corrected ID and new controls.

    0 讨论(0)
  • 2020-12-25 12:35

    I had this happen a few times and it happened again today for a new reason. I normally run my project through IIS but needed to run it locally to debug. I normally run on port 80 in IIS and 81 in debug, but I had some settings in the web.config that used 80 so I just killed the site in IIS and switched the website to port 80 in the project settings. For whatever reason, this messed everything up and created the problem described in the OP. I started trying things one by one, including all the advice mentioned here, but switching the port back to 81 in the project settings is what ended up working.

    0 讨论(0)
  • 2020-12-25 12:36

    In my case, I was working with some old web site code, which I converted to a VS2008 solution. I encountered this same problem.

    For me, the fix was to right-click the Web Sites project in the Solution Explorer and select Convert to Web Application. This created designer.cs files for all pages, which did not yet have these files before.

    0 讨论(0)
  • 2020-12-25 12:36

    we cannot change the code when the application is running .To do so first click on the stop button on the top which will halt your application .now click on the button in design mode ,it will insert the code in .aspx.cs file ,then write the code in it

    0 讨论(0)
  • 2020-12-25 12:37

    For me, deleting/renaming the files in the following location worked:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myvirtualwebsite\e331e0a9 
    
    0 讨论(0)
提交回复
热议问题