我有一个QuestionControl.ascx和一个QuestionControl.ascx.cs后面的代码复制到一个新项目的文件后面的代码。当我建立这个项目在隐藏文件在ASCX宣布控制代码的任何引用给了我这个错误:文件后面的代码无法识别* .ascx中的控件
'QuestionControl' does not contain a definition for 'rdbtnlstQuestion1' and no extension method 'rdbtnlstQuestion1' accepting a first argument of type 'QuestionControl' could be found (are you missing a using directive or an assembly reference?)
这是在我的*的.ascx顶部:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="QuestionControl.ascx.cs" Inherits="QuestionControl" %>
我以前也试过代码隐藏:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QuestionControl.ascx.cs" Inherits="QuestionControl" %>
这是我在代码隐藏文件类的顶部,它不包含在一个命名空间:
public partial class QuestionControl : System.Web.UI.UserControl
{
如果在其上添加另一个带有其他控件的空白ascx,那么该控件是否也无法编译? – Tejs 2010-05-21 15:15:01
.NET框架的哪个版本是这样的?而且,可以肯定的是,这是MVC还是WebForms? – 2010-05-21 15:15:29
你检查过命名空间吗? – Glennular 2010-05-21 15:18:32