Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在某个 Control 文件夹中放置了 5 个用户控件,在运行时基于一些 ID 我想将用户控件从 Control 文件夹加载到 aspx 页面。任何人都可以告诉我应该如何传递该 ID 来修复在运行时将哪个用户控件加载到某个 div 中。
在页面初始化中
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