Hi,
This is normal. "<%= %>" is the correct syntax. However you can not have this and have code modifying the same control's Control collection at the same time. Move the whole block outside of the control you are trying to modify should be fine. For example, the following code is wrong:
Code: HTML/ASPX
<asp:Panel runat="server" id="Panel1">
<%=Whatever%>
</asp:Panel>
Code: C#
Panel1.Controls.Add(new LiteralControl("test"));
The following code is correct:
Code: HTML/ASPX
<asp:Panel runat="server" id="Panel1">
<%=Whatever%>
<asp:Panel runat="server" id="Panel2">
</asp:Panel>
</asp:Panel>
Code: C#
Panel2.Controls.Add(new LiteralControl("test'));
The difference is for the first case, the parent control of the "<%= =>" block is the same control that you are trying to add child controls to (both are Panel1), while as for the second case they are not the same (one is Panel1 and one is Panel2).
This is a general ASP.NET rule that has nothing to do with our controls. So it applies to any control.
Thanks!