I have been having a similar problem. I have written some client-side
script to set page focus and window scoll on postback. The script
needs to be written at runtime as the focus depends on the control
that caused the postback.
It seems the script will only work if it is placed within the <body>
tags but outside of the <form> tags. That is where my problem lies;
programmatically created an HtmlGenericControl and set IT's InnerHtml to
my
string variable. than I simply added the control to the page's control
collection.
However I found that this placed the Control outside the <html> tags
of the page and it didn't work. I'm pasting the C# code from the
code-behind file I used below:
string strScript = "<script language=jscript> ...";
ctlGeneric = new HtmlGenericControl();
ctlGeneric.InnerHtml = strScript;
Page.Controls.Add(ctlGeneric);
Perhaps someone could help me see where I've gone wrong?
Thanks,
Joanne