Just before (or during) rendering page I would like to append a piece of code (java script). However when I try to add new LiteralControl via Page.Controls property I get an error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
How to get round that issue?
To avoid that problem do the following:
<asp:Placeholder id="Placeholder1" runat="server" /> control in your ASPXIn code behind add the control to the Controls collection of that placeholder:
Placeholder1.Controls.Add(myControl);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With