Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) asp.net
Issue:
Server Error in 'ASP.Net' 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.
Resolution:
If script files exist in head section of web form, master page or in content page, remove JavaScript from the header section of page and add it to body of the page and run your application it will work for you.
or replace the codeblock with <%# instead of <%=.
This way you can resolve the above issue.
Comments
Anonymous
December 12, 2013
Why?Anonymous
December 12, 2013
Mark, Can be more specific?Anonymous
February 17, 2014
Thanks a lot :)Anonymous
February 18, 2014
thanks but why we have to do like this???Anonymous
February 23, 2014
It Works. Thanks :)Anonymous
March 04, 2014
Sorry! still not working!Anonymous
March 19, 2014
Not WorkingAnonymous
March 20, 2014
Thanks!!!Anonymous
April 02, 2014
it works, thanksAnonymous
April 22, 2014
its working..Thanks.Anonymous
May 15, 2014
super..........pppp goodAnonymous
June 22, 2014
page.header.databind();Anonymous
July 24, 2014
In my Javascript in Markup, a code was commented out which contained the characters <% ... %>...which was creating this error. Completely removed it and the error vanished.Anonymous
August 04, 2014
Thanks Pradeep it helpsAnonymous
August 12, 2014
yeah its working thanks a lot.Anonymous
August 31, 2014
thankyou very muchAnonymous
September 01, 2014
IN MASTER PAGE SCRIPT TAG PASTE BEFORE </BODY> TAGAnonymous
September 25, 2014
its not working when we use javascipt fileAnonymous
September 28, 2014
It worked... ThanksAnonymous
October 07, 2014
thanks, it helps me.Anonymous
November 14, 2014
thank you very much! It saved my time so much!Anonymous
April 27, 2015
Please try changing your.net clr version (if it is 4.0 try changing it to 2.0) and run,it worked for me .Anonymous
May 26, 2015
The comment has been removedAnonymous
May 29, 2015
Replacing the codeblock with <%# instead of <%= renders nothingAnonymous
February 10, 2016
Thanks a lot, you save me a bunch of time from headache.