簡體   English   中英

如何在運行時加載用戶控件,在aspx頁面?

[英]How to load user control at run time, in a aspx page?

我在一些Control文件夾中放置了5個用戶控件,在運行時根據一些ID我想將用戶控件從Control文件夾加載到aspx頁面。 任何正文都可以告訴我應該如何傳遞該ID來修復在運行時加載某個div的用戶控件。

在Page Init中

UserControl uc = new UserControl();
string ID = "1";
string userControl ="UC" + ID + ".ascx";
uc = LoadControl(userControl) as UserControl;
PlaceHolder1.Controls.Add(uc); //some place holder to place controls

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM