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

RadToolbar Javscript Error

1 Answer 50 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 05 Nov 2008, 03:22 PM
I have a RadToolbar that is created using the following code:

            <telerik:RadToolBar ID="RadToolBar1" runat="server" OnButtonClick="RadToolBar1_ButtonClick" 
                CssClass="Toolbar" Skin="WebBlue" OnClientButtonClicked="ToolbarButtonClicked"
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                <Items>                     
                    <telerik:RadToolBarButton runat="server" ImageUrl="~/Images/new_note.png" Text="Notes"
                    </telerik:RadToolBarButton>                   
                </Items> 
            </telerik:RadToolBar> 

I also have a a RadDock on the same page:
<telerik:RadDockLayout ID="RadDockLayout1" runat="server" EnableAjaxSkinRendering="False" 
                EnableEmbeddedBaseStylesheet="False" EnableEmbeddedSkins="False"
                <telerik:RadDockZone ID="DocumentDockZone" runat="server" Height="105%" Width="100%" 
                    FitDocks="False" bgcolor="#666666" BackColor="#666666" BorderStyle="None" BorderWidth="0px">                     
                    <telerik:RadDock ID="NotesDock" runat="server" Width="99%" Skin="Office2007" DefaultCommands="ExpandCollapse" 
                        DockHandle="None" Title="Notes" DockMode="Floating" ForbiddenZones="DocumentDockZone"
                        <ContentTemplate> 
                            <uc5:Notes ID="Notes1" runat="server" /> 
                        </ContentTemplate> 
                    </telerik:RadDock> 
                </telerik:RadDockZone> 
</telerik:RadDockLayout>

I have the following javascript code on the same page:

        function ToolbarButtonClicked(sender, args)  
        { 
            var button = args.get_item(); 
            var notesDocks = $find("<%= NotesDock.ClientID %>"); 
             
            if (button.get_text() == "Notes")  
            { 
                 
                alert("Notes click"); 
                args.set_cancel(true); 
                 
            } 
        }  

When the page attempts to load I get the following Exception:

System.Web.HttpException: "Error executing child request for Default.aspx."
InnerException: System.Web.HttpUnhandledException: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."

This error only occurs when I attempt to get the NotesDock control in the javascript line "var notesDocks = $find("<%= NotesDock.ClientID %>");" But I need a reference to this object because I want to call notesDock.set_closed(false) at some point.

Any idea what might be causing this problem?

1 Answer, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 05 Nov 2008, 09:46 PM
Hey Andrew,

I just tested your code and it looks like if you put your script block into a RadScriptBlock that it solves the error you're having. :)

i.e.
    <telerik:RadScriptBlock runat="server">  
 
    <script type="text/javascript" language="javascript">  
        function ToolbarButtonClicked(sender, args) {  
            var button = args.get_item();  
            var notesDocks = $find("<%= NotesDock.ClientID %>");  
 
            if (button.get_text() == "Notes") {  
                alert("Notes click");  
                args.set_cancel(true);  
            }  
        }     
          
    </script> 
    </telerik:RadScriptBlock> 
Tags
ToolBar
Asked by
Andrew
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
Share this question
or