Welcome to Comunidade Bloggers |create|it| Sign in | Join | Help
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

Because I have pages with the markup <%= someVariable%> like

<script type="text/javascript">
            
  function ConfirmCallBack(arg)
  {
    if (arg)
     <%= this._nextPostBack%>
  }
</script>

I get the following error: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %><% ... %>)."

To correct it I had to change from

<%= this._nextPostBack%>

to

<%# this._nextPostBack%>

and in the PageLoad event add the call to Page's DataBind method

protected void Page_Load(object sender, EventArgs e)
{
  ...
  Page.DataBind();
}
Posted: Wednesday, May 07, 2008 5:37 AM by ricardo.costa
Filed under: ,

Comments

No Comments

Anonymous comments are disabled