Address The Controls collection cannot be modified the control contains code blocks

  • 2020-05-10 17:59:27
  • OfStack

If included in.aspx or.ascx < %= % > , and use the control in AjaxToolkit in.aspx,.ascs, then it is likely to raise the "The Controls collection cannot be modified the the control contains code blocks" exception.

The solution is as follows

1. The < % = change to < %#

2. In the Page_Load event on the.asp or template page, add the following code
 
Page.Header.DataBind(); 


Related articles: