This is a migrated thread and some comments may be shown as answers.

Question about use of RadCodeBlock

1 Answer 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 10 Dec 2012, 05:50 PM
I have a Dot Net 4.0 web app with quite a few of those <% %> tags scattered throughout the scripts of various pages.  Most pages have at least a little JavaScript, mostly routine stuff like custom validator handlers for dropdowns.  

Today I got an exception: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

This was fixed by placing the script block on that page in a RadCodeBlock.

I've been looking at this documentation: http://www.telerik.com/help/aspnet-ajax/ajax-radscriptblock-radcodeblock.html.

It occurs to me that this RadCodeBlock is only the second one I've added to the entire project.  I've not had problems with other pages.

In general would you say that it's good coding practice to routinely enclose all JavaScript blocks in RadCodeBlocks?

1 Answer, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 13 Dec 2012, 12:55 PM
Hi Boris,

Yes, it is best practise to wrap all the JavaScript into RadCodeBlock control in order to avoid the mentioned error. Also please note that the RadCodeBlock should be used not only in case Javascript is added but for every server tag you have placed in the page markup.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Boris
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or