Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have create a user control and used in few pages.
In all the pages it works fine but where ever I am using calendar extender, it show following error.
Kindly suggest.

XML
Server Error in '/new' Application.

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Posted

Have a look at below link:
The Controls Collection Cannot Be Modified Because the Control Contains Code Blocks[^]

Also you will find more answers here[^]
 
Share this answer
 
Hi

start the code block with <%# instead of <%=


ASP.NET
<head id="head1" runat="server">
  <title>My Page</title>
  <link href="css/common.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="<%# ResolveUrl("~/javascript/leesUtils.js") %>"></script>
</head>


Check this solution:-


http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/[^]


Please Mark as Answer if find helpful..

Happy coding...
 
Share this answer
 
Comments
Arunprasath Natarajan 3-Jan-13 23:08pm    
Tan q, It helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900