Script in RadCodeBlock not found when used in OnClientDoubleClick

5 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 19 Aug 2009 Link to this post

    Hello,

    I want to do some client adaptation on a node doubleclick and I have to customize my script depending language so I used a radcodeblck for it.
    But I get an error on Page, the function called by TreeView OnClientDoubleClick is not found .
    If I look to page source in browser, the function is here and well formated ?
    Here is my code
    <Telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
    <script type="text/javascript" language="javascript">  
        function TemplateDoubleClick(sender, eventArgs) {  
            var node = eventArgs.get_node();  
            var cat = node.get_category();  
            for (var i = 0; i < node.get_nodes().get_count(); i++) {  
                var nd = node.get_nodes().getNode(i);  
                var cat2 = nd.get_category();  
                if (cat2 == 'Id')  
                    nd.set_text('<%= Localize("NEWID","New Id") %>');  
                else if (cat2 == 'Icon')  
                    nd.set_text('<%= Localize("NEWICON","New Icon url") %>');  
                else if (cat2 == 'IsProfile')  
                    nd.check();  
            }  
            return;  
        }  
    </script> 
    </Telerik:RadCodeBlock> 
     
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" ValidationGroup='Main' SelectedIndex='0' > 
        <Tabs> 
            <telerik:RadTab runat="server" TabIndex='0' PageViewID="PageView1" Text="Page 1" /> 
            <telerik:RadTab runat="server" TabIndex='1' PageViewID="PageView2" Text="Page 2" /> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <telerik:RadMultiPage ID="RadMultiPage1" Runat="server" SelectedIndex='0' > 
        <telerik:RadPageView ID="RadPageView1" runat="server">  
        </telerik:RadPageView> 
        <telerik:RadPageView ID="PageView2" runat="server">  
                    <telerik:RadTreeView ID="RadTemplatesTree"  CssClass='TreeView' OnClientDoubleClick='TemplateDoubleClick'  AllowNodeEditing='true' CheckBoxes="true"  EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="true"   
                                MultipleSelect="false"  runat="server">  
    ..... 


    Where is my error.

    Thanks.
    CS
  2. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 19 Aug 2009 Link to this post

    Just as complementary info, in the browser's page source code the script appears after the radtreeview init method, I don't understand why it is moved there, seems to be related to radcodeblock because without it the function is before just as placed in the aspx code and it is found by treeview...


    CS
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 20 Aug 2009 Link to this post

    Hi Christian Surieux,

    I could not reproduce the problem using the code you supplied. Here it is:

    <Telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">   
    <script type="text/javascript" language="javascript"
        function TemplateDoubleClick(sender, eventArgs) {alert(1); 
            var node = eventArgs.get_node(); 
            var cat = node.get_category(); 
            for (var i = 0; i < node.get_nodes().get_count(); i++) { 
                var nd = node.get_nodes().getNode(i); 
                var cat2 = nd.get_category(); 
                if (cat2 == 'Id') 
                    nd.set_text('new id'); 
                else if (cat2 == 'Icon') 
                    nd.set_text('New Icon url'); 
                else if (cat2 == 'IsProfile') 
                    nd.check(); 
            } 
            return; 
        }   
    </script>  
    </Telerik:RadCodeBlock>  
      
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" ValidationGroup='Main' SelectedIndex='0' >  
        <Tabs>  
            <telerik:RadTab runat="server" TabIndex='0' PageViewID="PageView1" Text="Page 1" />  
            <telerik:RadTab runat="server" TabIndex='1' PageViewID="PageView2" Text="Page 2" />  
        </Tabs>  
    </telerik:RadTabStrip>  
    <telerik:RadMultiPage ID="RadMultiPage1" Runat="server" SelectedIndex='0' >  
        <telerik:RadPageView ID="RadPageView1" runat="server">  page 1 
        </telerik:RadPageView>  
        <telerik:RadPageView ID="PageView2" runat="server">   
                    <telerik:RadTreeView ID="RadTemplatesTree"  CssClass='TreeView' OnClientDoubleClick='TemplateDoubleClick'  AllowNodeEditing='true' CheckBoxes="true"  EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="true"    
                                MultipleSelect="false"  runat="server"
                                <Nodes> 
                                    <telerik:RadTreeNode Text="root"></telerik:RadTreeNode> 
                                </Nodes> 
                    </telerik:radtreeview>                
    </telerik:RadPageView> 
    </telerik:RadMultiPage>   

    I see no errors and the alert is executed. I suppose something else is messing the code.

    Sincerely yours,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 20 Aug 2009 Link to this post

    Hello,

    I suppose it is the <%= Localize("NEWID","New Id") %>' that change the result.
    my Localize method is from a library I Import in the ascx, it take care to translate the key sent, very common.

    And it is working well because the broser source code contains the 'translated value' .... but in IE7/8 code is pushed after your Init call for RadTreeView and it crashes radtreeview init, nothing being displayed.

    CS
  6. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 21 Aug 2009 Link to this post

    Hi,

    Just to add that I found the error which was on my side....I apology.
    It was a translated string containing the ' char....


    Anyay thanks for support.
    CS
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017