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

前端 未结 16 1422
面向向阳花
面向向阳花 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:52

    This can also happen if the Inherits property on the source page doesn't match the class name in the code behind. Generally speaking, this would probably only happen if you copy/pasted a .ascx/.aspx file and forgot to update it.

    Example:

    <%@ Control AutoEventWireup="false" CodeBehind="myControl.ascx.vb" Inherits="myProject.myWrongControl" %>
    

    The the code behind class:

    Partial Public Class myControl
    

提交回复
热议问题