【发布时间】:2011-02-22 10:07:23
【问题描述】:
我有一个 QuestionControl.ascx 和一个 QuestionControl.ascx.cs 代码隐藏在我复制到一个新项目的文件中。当我构建项目时,代码隐藏文件中对 ascx 中声明的控件的任何引用都会给我这个错误:
'QuestionControl' 不包含 'rdbtnlstQuestion1' 的定义和 没有扩展方法 'rdbtnlstQuestion1' 接受第一个 'QuestionControl' 类型的参数 可以找到(您是否缺少 使用指令或程序集 参考?)
这是我的 *.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
{
【问题讨论】:
-
如果您添加另一个空白 ascx 和另一个控件,该控件是否也无法编译?
-
这是哪个版本的 .NET 框架?而且,为了确定,这是 MVC 还是 WebForms?
-
你检查命名空间了吗?