【发布时间】:2011-12-15 17:39:16
【问题描述】:
我非常熟悉以编程方式加载用户控件,但是我想使用 web.config 中设置的引用而不是页面上的 <%@ Reference %> 声明。
<pages>
<controls>
<add tagPrefix="uc" tagName="Menu" src="~/App_Controls/MainMenu.ascx" />...
如何使用 web.config 引用而不是路径或寄存器声明以编程方式在我的页面上加载此控件。
Control uc = (Control)Page.LoadControl("~/usercontrol/WebUserControl1.ascx");
plhStatCounts.Controls.Add(uc);
谢谢
【问题讨论】:
-
您提到了以编程方式添加用户控件,但编程用户控件不需要使用@Reference 部分或网络配置,所以您打算静态定义用户控件吗?