findItemByValue not working using concatenated string as parameter

2 posts, 0 answers
  1. jlj30
    jlj30 avatar
    101 posts
    Member since:
    Jan 2011

    Posted 12 Jun 2015 Link to this post


    I'm sure this is something silly on my part, but I can't spot it.

    The following code works:

    var x = 'text';
    var y = 'Red';
    var selectedColorButtonValue = String(x + y);
    var selectedColorButton = toolBar.findItemByValue(selectedColorButtonValue);

    Now, since the actual value of y is dynamic and only known at run time, I have this code:

    var selectedColorButtonValue = getColorButtonValue(fontColor); // Returns 'Red' for this demo
    selectedColorButtonValue = String('text' + selectedColorButtonValue);
    var selectedColorButton = toolBar.findItemByValue(selectedColorButtonValue);

    The above does NOT work. The toolbarbutton that I'm trying to find is not found!

    The toolbarbutton in question is one of several items in a RadToolBarSplitButton.

    I have written to the console, and the value of selectedColorButtonValue appears fine.

    Can anyone spot what I'm doing wrong.




  2. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 17 Jun 2015 Link to this post


    Make sure that you pass the correct id to $find:

    function findItem() {
        var toolBar = $find("<%= toolbar.ClientID %>");
        var x = 'text';
        var y = 'Red';
        var selectedColorButtonValue = String(x + y);
        var selectedColorButton = toolBar.findItemByValue(selectedColorButtonValue);
    <telerik:RadToolBar runat="server" ID="toolbar">
                 <telerik:RadToolBarButton Text="Button" Value="textRed">

    Hristo Valyavicharski
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top