0

我使用Visual Studio 2010開發的Sharepoint 2010的SharePoint的WebParts - 作爲了.Designer.cs基礎用戶控件生成自定義用戶控件文件

一個網絡的一部分,我創建了我想要的用戶控件包括在我的網頁部分。然而,當我滴在MyWebPart.ascx用戶控制(在設計視圖)它獲取生成作爲MyWebPart.ascx.designer.cs如下:

protected global::System.Web.UI.UserControl customUserControl; 

代替:

protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl; 

它工程,但我需要在後面的代碼中將customUserControl投射到具體的MyUserControl中(例如,如果想在PageLoad事件中設置它的一些屬性)。

我該如何解決這個問題?

回答

1

到目前爲止,我的解決方案是在yourpage.cs中聲明protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl。所以它可以正確地得到實際的類型。

我認爲這是最簡單的「解決方案」。不過,我仍然感到醜陋和怪異。

如果您有更好的解決方案,請與我分享。