[英]Asp.net Chart doesn't work in Page_Load when using LoadControl + UserControl
I have a UserControl which contains an asp.net Chart. 我有一个包含asp.net图表的UserControl。 If I reference the user control statically in the page, the chart displays, ie:
如果我在页面中静态引用用户控件,则会显示图表,即:
<uc:UserControl1 id="UserControl1" runat="server" />
However, if I load the user control from the codebehind in the Page_Load event, the Chart does not display: 但是,如果我从Page_Load事件中的代码后面加载用户控件,则图表不会显示:
Panel1.Controls.Add(this.LoadControl("UserControl1.ascx"));
I have other controls in the user control such as a GridView, and both of the above methods work for those controls. 我在用户控件中还有其他控件,例如GridView,并且上述两种方法都适用于这些控件。 The only control that isn't working is the asp.net Chart control.
唯一不起作用的控件是asp.net Chart控件。
Any ideas? 有任何想法吗?
当您在后面的代码中实例化动态创建的用户控件时,仍然必须将引用设置为aspx页面。
<%@ Reference Control="UserControl.ascx" %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.