2
votes

I have a UserControl which contains an asp.net Chart. If I reference the user control statically in the page, the chart displays, i.e.:

<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:

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. The only control that isn't working is the asp.net Chart control.

Any ideas?

1

1 Answers

0
votes

When you instantiate dynamically created user controls in the code behind, you still have to set the reference is the aspx page.

<%@ Reference Control="UserControl.ascx" %>