2011-11-05 90 views
1

我已經創建了一個用戶控件,並通過將其添加到aspx頁面進行了測試,它工作得很好。四部分名稱用戶控件Web部件-SP 2007

我寫了用戶控件,以便我可以在我的Sharepoint門戶中使用。

我已經創建了一個sharepoint webpart項目,並向該方法添加了以下代碼。

public class Nov059PM : System.Web.UI.WebControls.WebParts.WebPart 
{ 
    Control _myControl; 

    protected override void CreateChildControls() 
    { 
     this.Controls.Clear(); 

     _myControl = this.Page.LoadControl("~/usercontrols/Grid.ascx"); 

     this.Controls.Add(_myControl); 
    } 
} 

我已經放置在Grid.ascx在C:\的Inetpub \ wwwroot的\ WSS \ VirtualDirectories \ myportno \用戶控件文件夾。

我已經構建了webpart並進行了部署。

當我嘗試使用它,它說:

Could not load type 'Grid.Grid'.

Source Error:

Line 1: <%@ Control Language="C#" AutoEventWireup="true" Inherits="Grid.Grid" %>

我在想,繼承應該有四個部分組成的名稱。如何爲同一個生成四個部分名稱?

回答

2

您部署了.ascx文件,但忘記了包含Grid.Grid類的程序集或代碼隱藏文件。

1

如果用四部分名稱表示完全限定名稱,則可以學習如何找到它on msdnhere

至於你的具體問題,馬雷克說,檢查你是否正在部署該類。

1

你必須在

<%@控制語言= 「C#」 繼承=「Grid.Grid,網格中添加完全集版本,版本= 1.0.0.0,文化=中性公鑰= PUBKEYTOKEN 「%>

並將Grid.dll放入GAC。

在此之前,您必須在Grid.dll中應用SNK。