我有一個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