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

Accesing Client Object in User Control

3 Answers 66 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Peichung
Top achievements
Rank 1
Peichung asked on 04 Nov 2008, 03:44 AM
Hi,

I have a RadCombobox containing a RadTreeView ItemTemplate.  Everything works fine when I use it in a web page.  However, when I move it to a user control, I wasn't able to access to the TreeView client object anymore. Here is how I try to get checked tree nodes displayed in RadCombox's text:

 
    function OnDropDownClosed(sender, eventArgs)  
    {  
        var treeView = $find('<%# RadComboBox1.Items[0].FindControl("RadTreeView1").ClientID %>');  
        var nodes = treeView.get_checkedNodes();  
 
        var str = '';  
        for (var i=0; i<nodes.length;i++)  
        {  
            str += ', ' + nodes[i].get_text();  
        }  
        sender.set_text(str);  
    }  
 

The error message I got was "'null' is null or not an object."  Please help.  Thanks,

Peichung

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 04 Nov 2008, 09:58 AM
Hello Peichung,

This is because the ClientID of the combobox is not RadComboBox1 anymore.

You can try getting the treeview instance in this way:

var treeView = sender.get_items().getItem(0).findControl("RadTreeView1"); 

I hope this helps.

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Peichung
Top achievements
Rank 1
answered on 04 Nov 2008, 12:29 PM
Hi Veselin,

Thanks for the reply.  I tried that too, but it didn't work either.  I guess the name of the TreeView (i.e., RadTreeView1 in my case) has been changed in the user control scenario.  .NET added some prefix to uniquely identify the control.  I have no problem of getting the first item in the combobox like sender.get_items().getItem(0).  It is the findControl() method that throws the exception.  Is there any way that I can get the TreeView object without using its name?  Thanks,

Peichung
0
Veselin Vasilev
Telerik team
answered on 07 Nov 2008, 10:19 AM
Hello Peichung,

I created a sample project and it worked just fine. Please download it and give it a try.

Let me know what should I do to reproduce the problem.

All the best,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Peichung
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Peichung
Top achievements
Rank 1
Share this question
or