Adding to the BODY element
Just before (or during) the rendering page, I would like to add a piece of code (java script). However, when I try to add a new LiteralControl via the Page.Controls property, I get the error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
How do I get around this problem?
+2
a source to share
2 answers
You can just add LiteralControl
to your markup and set its property Text
from code.
EDIT:
Another (and probably more correct) option is to use ScriptManager.RegisterClientScriptBlock
0
a source to share