How to access and set visibility of child controls from ClientSelectedIndexChanged event handler?

6 posts, 1 answers
  1. KN425000
    KN425000 avatar
    16 posts
    Member since:
    Aug 2010

    Posted 18 Jul 2011 Link to this post

    I have a RadListBox, where, inside the ItemTemplate, I have a RadComboBox, another RadComboBox, and a RadTextBox.  Based on the selected value in the first RadComboBox (captured in ClientSelectedIndexChanged), I want to show or hide the other controls.  That is, if the value in the first RadComboBox is "apple," I want to show the second RadComboBox and hide the RadTextBox.  However, if the value in the first RadComboBox is "banana," I want to hide the second RadComboBox and show the RadTextBox.

    What is the normal way of doing this from this event handler?

    Thanks
  2. KN425000
    KN425000 avatar
    16 posts
    Member since:
    Aug 2010

    Posted 18 Jul 2011 Link to this post


    In case what I'm asking is not obvious, I want to do the following:

    function RadComboBox1_ClientSelectedIndexChanged(sender)
    {
         // get reference to 2nd combobox within the ItemTemplate of this list item
         var secondComboBox = /* how do I get a reference to this?  */
         var textBox = /* how do I get a reference to this? */
           
         if (sender._text == "apple")
         {
             secondComboBox.hide();   // what's the right way to do this?
             textBox.show();
         }
         else
         {
              secondComboBox.show(); 
             textBox.hide();
     
         }
     
     
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 20 Jul 2011 Link to this post

    Hello Kn425000,

    Please review the support ticket regarding the same issue.

    I am attaching the sample project from the support ticket, that implements your scenario.

    Greetings,
    Peter Filipov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. KN425000
    KN425000 avatar
    16 posts
    Member since:
    Aug 2010

    Posted 21 Jul 2011 Link to this post


    In the following event handler, I'm getting "Object doesn't support this property or method" on the line fo
    args.set_cancel(true)
    :

    function OnClientClicked(sender, args) {
     
                var index = GetItem(sender);
     
                listbox.deleteItem(listbox.getItem(index));
     
                args.set_cancel(true);
            }

    Any ideas?


    Edit:   It looks like args.set_cancel(true) only works in the OnClientClicking event handler, not the OnClientClicked event handler that the solution proposes.
  6. KN425000
    KN425000 avatar
    16 posts
    Member since:
    Aug 2010

    Posted 21 Jul 2011 Link to this post


    I had to change

    function pageLoad() {
     
                listbox = $find("RadListBox1");
            }


    to use $find("<%=RadListBox1.ClientID %>").  Was that a typo in the proposed solution, or are there some conditions in which the proposed solution works?
  7. KN425000
    KN425000 avatar
    16 posts
    Member since:
    Aug 2010

    Posted 22 Jul 2011 Link to this post

    After making the fixes above to the proposed solution, my form works, so I'm marking this closed.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017