Home » Programming / Coding

System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks

17 November 2008 494 views No Comment

The error occurs when a JavaScript code block is placed in the head of MasterPage. Place the code block in a contentplaceholder to resolve the issue.

<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>
</head>

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.