What can cause:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
I ask because, the code does not contain code blocks. Anywhere. There is not a single <%= %> block on any page in the entire site. All i have are the <%@ %> directive lines.
Edit:
Below is the code causing the error.
/// <summary>
/// Adds javascript variables to a page so that ASP control ID are accessable via Javascript. The
/// variable names are ASP_ControlID.
/// </summary>
/// <param name="page">The Page to add the javascript to</param>
/// <param name="ctls">The controls to make accessable</param>
public static void addJavascriptIDs(Page page, params Control[] ctls)
{
Literal litJS = new Literal();
litJS.Text = getJavascriptIDs(ctls);
page.Form.Controls.Add(litJS); ////////// <-- Error Here
}
/// <summary>
/// Returns a string containing the javascript to allow javascript to access
/// ASP controls.
/// </summary>
/// <param name="ctls">The HTML and javascript to create the javascript variables</param>
/// <returns>The script</returns>
public static string getJavascriptIDs(params Control[] ctls)
{
string js = "\n<script type=\"text/javascript\">\n";
foreach (Control ctl in ctls)
js += "\tvar ASP_" + ctl.ID + " = '" + ctl.ClientID + "';\n";
js += "</script>\n\n";
return js;
}
This is the Page_Load function:
protected void Page_Load(object sender, EventArgs e)
{
formHowHear.Attributes.Add("onChange", "displayOther(this);");
LoadValues();
if (!IsPostBack)
{
LoadDefaults();
BindValidation();
}
else
{
Submitted();
}
CMSUtil.addJavascriptIDs(this, formEmail1, formEmail2, formUsername);
CMSUtil.addJavascriptIncludes(Page,
ResolveUrl("~/js/jquery-1.4.2.min.js"),
ResolveUrl("~/admin/js/TVCMS.js")
);
}