After trying to understand why client code is not rendered in a page (injected by user control) I found this link, it turns out you must have a form tag for it to work (Page.RegisterClientScriptBlock did declare this but ClientScriptManager.RegisterClientScriptBlock which I use does not say anything regarding this).
I am using Visual studio 2005.
Does anyone know if this has been solved?
Edit:
To clarify, I want my control to add javascript code to the head section of the page without having to use the
<form runat='server'
I have tried adding it using:
HtmlGenericControl x = new HtmlGenericControl('script'); x.InnerText = 'alert('123');'; Page.Header.Controls.Add(x);
But this did not work for me.
Got it!
My mistake was not doing it in the OnPreRender method (I used the Render method).
Now all that is needed is – like Mitchel Sellers wrote, set the header to runat server and than add to it’s controls:
Thanks for pointing me to the right direction!