Home
 Index > ASP.NET Web Applications > The Controls collection cannot be modified beca...

ASP.NET Web Applications:  AJAX , Debugging

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

The error was thrown while attempting to add an AJAX Extender, such as a Calendar extender, to a textbox.

Added on 3 Sep 2008

General Solutions:

Solution Summary:
The error occurs when a code block is placed in the MasterPage. Place the code block in a placeholder to resolve the issue.
Solution Details:

When adding AJAX extenders to your Web page, it will attempt to register  scripts in the head.  If code blocks are present in the MasterPage, an error might occur. 

To resolve this issue, simply move the code block into a placeholder in the head of your MasterPage, like so:

<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="myPlaceholder" runat="server">
    <script language="javascript" type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/global.js")%>"></script>
    </asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</
head>
Was this solution useful? Yes No Added on 3 Sep 2008
Rating: 

Copyright 2017 © E-Centric, Inc. | Terms of Use