我有一个 QuestionControl.ascx 和一个 QuestionControl.ascx.cs 代码隐藏在我复制到一个新项目的文件中。当我构建项目时,代码隐藏文件中对 ascx 中声明的控件的任何引用都会给我这个错误:
“QuestionControl”不包含“rdbtnlstQuestion1”的定义,并且找不到接受“QuestionControl”类型的第一个参数的扩展方法“rdbtnlstQuestion1”(您是否缺少 using 指令或程序集引用?)
这是我的 *.ascx 的顶部:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="QuestionControl.ascx.cs" Inherits="QuestionControl" %>
我也尝试过 CodeBehind:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QuestionControl.ascx.cs" Inherits="QuestionControl" %>
这是代码隐藏文件中我的类的顶部,它不包含在命名空间中:
public partial class QuestionControl : System.Web.UI.UserControl
{