RadToolbar Javscript Error

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    104 posts
    Member since:
    May 2008

    Posted 05 Nov 2008 Link to this post

    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> 
                        <telerik:RadToolBarButton runat="server" ImageUrl="~/Images/new_note.png" Text="Notes"

    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"
                                <uc5:Notes ID="Notes1" runat="server" /> 

    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"); 

    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?
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 05 Nov 2008 Link to this post

    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. :)

        <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");  
Back to Top