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

LoadOnDemand RadComboBox in a UserControl

4 Answers 102 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 10 Sep 2008, 01:17 AM
I have a RadComboBox in a UserControl. The RadComboBox has EnableLoadOnDemand = true. How do I get the value of the combobox on the client side from a parent page or container control? I have tried:

var foo = $find('<%=this.UserControlInstanceName.ClientID %>');
foo.get_value();
foo.get_text();

and

var foo = $find('<%=this.UserControlInstanceName.FindControl("RadComboBoxName").ClientID %>');
foo.get_value();
foo.get_text();

In both cases, it simply returns the default of the combo box instead of what is current set.

4 Answers, 1 is accepted

Sort by
0
Thomas
Top achievements
Rank 1
answered on 10 Sep 2008, 06:57 PM
I found the problem and have a solution. The issue is that the call to this.MyUserControl.ClientID returned the ClientID for the UserControl as opposed to ClientID of the ComboBox in the UserControl.

My solution was to created a public property called "ComboBoxClientID" on the UserControl which returned the ClientID of the ComboBox. My javascript code then looks like:

var foo = $find("<%= this.MyUserControl.ComboBoxClientID %>");
foo.get_value();
0
Veselin Vasilev
Telerik team
answered on 15 Sep 2008, 08:58 AM
Hello Thomas,

Thank you for sharing the approach with the community.

Another implementation would be to have a global javascript variable:
var combo;

and subscribe to the OnClientLoad client-side event and in its handler set:

combo = sender;


Regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Thomas
Top achievements
Rank 1
answered on 15 Sep 2008, 05:03 PM
Hi Veskoni,

Unfortunately, that approach will not work if there are multiple instances of the UserControl on the same form.
0
Veselin Vasilev
Telerik team
answered on 16 Sep 2008, 07:17 AM
Hi Thomas,

Yes, absolutely.

Sincerely yours,
Veskoni
the Telerik team

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