Home DotNet The Controls collection cannot be modified-because the control contains code blocks error
07.09.2010
Main Menu
Programming
.NET Controls
Operating System
Databases
Articles
Add to: Digg Add to: Del.icoi.us Add to: Reddit Add to: StumbleUpon Add to: Slashdot Add to: Yahoo Add to: Technorati Add to: Google
The Controls collection cannot be modified-because the control contains code blocks error

When you run the asp.net page you get the error "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)".

There are a few work around to this error and its depend on your situation.

1. Firstly if you put the runat="server" in the <head> tag then you might be able to solve this error by taking out the runat="server"

So instead of using

<head runat="server">

Try

<head>

2. In you code instead of using <%= myControl.ClientID %> try to use <%# myControl.ClientID %>.

So instead of using

<%= notation

Try

<%# notation.

If you are getting this error when using the Telerik suite then try the put your script code inside the RadCodeBlock .



Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."