2009-04-28 14 views
0

私はWebサイトプロジェクトをVS 2008のWebアプリケーションプロジェクトに変換していますが、動的に読み込むユーザーコントロールに関するクエリを実行しました。ウェブapplciationプロジェクトにupdateingときWebアプリケーションプロジェクト@Referenceタグ

<%@ Reference Control="~/UserControls/MyUserControl.ascx" %> 

し、ページに、私は単に...

Dim ucSupplierDetails As New ASP.usercontrols_myusercontrol_ascx 

と呼ばれるには、悲しいことに、これはもはや有効ラインではありません。代わりがありますか?

答えて

3

<%@ Import namespace="Namespace.Of.Your.Usercontrol" %>を使用してみてくださいは、代替です:

Dim ucSupplierDetails As New UserControl 
ucSupplierDetails.LoadControl("~/UserControls/MyUserControl.ascx") 
placeholder.Controls.Add(ucSupplierDetails) 

編集:ここでは 2番目のオプションで、手動で名前空間にユーザーコントロールを配置:

Namespace MyUserControlNamespace 

    Public Class MyUserControl Inherits System.Web.UI.UserControl 

    End Class 

End Namespace 

ユーザーコントロールのクラス宣言を変更するのを忘れないでください(継承する最後の行でttribute):

<%@ Control Language="VB" AutoEventWireup="true" 
    CodeFile="MyUserControl.ascx.vb" 
    Inherits="MyUserControlNamespace.MyUserControl" %> 

そして今、あなたはそれでそれらにアクセスすることができますが、名前空間です:

Dim ucSupplierDetails As New MyUserControlNamespace.MyUserControl 
2

動的にここにあなたのユーザーコントロールをロードする代わりに

関連する問題