私は柔軟なCompositeControlを構築しようとしています。いくつかのパラメータによっては、CompositeControlがCreateChildControlsメソッドで異なるユーザーコントロールをロードするようにしたいと思います。正確なUserControlsは設計時にはわかりません。 CompositeコントロールにUserControlを追加することはできますか?
はちょうど簡単な例として、私は「ハードコーディングされた」ユーザーコントロールを試み、それが失敗しました:protected override void CreateChildControls()
{
Control UserControlControl = Page.LoadControl(typeof(MyUserControl), null);
Controls.Add(UserControlControl);
Label RegularControl = new Label();
RegularControl.Text = "This gets displayed";
Controls.Add(RegularControl);
}
それは私が探しているものを達成することは可能ですか?
おかげ
何? – womp