I am trying to add a chart control to my .aspx page, but am getting the following error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
with this code:
protected void Page_Init(object sender, EventArgs e) {
if (Context.Items.Contains("ajaxChart")) {
ajaxChart = (bool) Context.Items["ajaxChart"];
}
if (Context.Items.Contains("chartControl") && ajaxChart) {
_ChartControl = (ChartControl) Context.Items["chartControl"];
}
if (_ChartControl != null) {
this.portletContent.Controls.Add(_ChartControl);
}
}
The aspx page itself has two <%...%> block calling methods in my code behind.
<body>
<div id="portletContent" runat="server">
<%=Render()%>
</div>
</body>
Has anyone solved this problem before? Is there another approach I can take to get around this. I basically need to inject this control into this page, and also run the Render() method inline at the right place