1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Controls collection cannot be modified because the control contains code blocks

Controls collection cannot be modified because the control contains code blocks

4 posts, 0 answered
  1. Chris Williams
    Chris Williams avatar
    14 posts
    Registered:
    25 Oct 2004
    04 Feb 2010
    Link to this post
    I've seen the other posts on this topic and they all seem to be related to moving the <%= %> out of the head area of the master page.  That is not the case in my solution.  All of my control blocks are in the body, as shown below:

    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="radScriptManager" runat="server">
            <Scripts>
                <asp:ScriptReference Path="~/js/jquery-1.4.1.min.js" />
                <asp:ScriptReference Path="~/js/swfobject.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            $(document).ready(function() {
            var so = new SWFObject('<%=Page.ResolveClientUrl("~/App_Themes/Sirana/flash/menu_v8.swf") %>', 'mymovie', '766', '98', '9', '', 'high');
            so.addParam("allowScriptAccess", "always");
            so.addParam("menu", "false");
            so.write("menu");
      
            var so = new SWFObject('<%=Page.ResolveClientUrl("~/App_Themes/Sirana/flash/header_v8.swf") %>', 'mymovie', '766', '305', '9', '', 'high');
            so.addParam("allowScriptAccess", "always");
            so.addParam("menu", "false");
            so.write("flash");
            });
        </script>

    As you can see I have a script that runs a Flash animation, and I've hooked it up to fire using JQuery.  I need to use the Page.ResolveClientUrl to locate the Flash file from whatever level I happen to be on.

    When I take out the Javascript, the page runs fine in the SiTeFinity designer.  However, whenever I include it, I get the "Controls collection cannot be modified because the control contains code blocks" error.

    Can you suggest a workaround?

    thanks,

    Chris

    Edit: The page still errors if I have empty Javascript brackets, like so:
    <script type="text/javascript">
    </script>

    I have to completely remove the brackets for the page to be editable.

  2. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Feb 2010
    Link to this post
    Hello Chris,

    Try registering the script in the head of your master page

    <script type="text/javascript" src="http://domain.com/js/swfobject.js"></script>

    You could also try using Page.ResolveUrl("~/pathtoObject/file.swf") in the code behind of your master page.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  4. Chris Williams
    Chris Williams avatar
    14 posts
    Registered:
    25 Oct 2004
    04 Feb 2010
    Link to this post
    +! to MB!  That approach worked.

    The approach recommended about registering the scripts in Head didn't help me, but the RadCodeBlock suggestion did the trick.

    Thanks!
Register for webinar
4 posts, 0 answered