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

RadComboBox AssociatedControlID

6 Answers 132 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
alexandrupaul
Top achievements
Rank 1
alexandrupaul asked on 15 Dec 2009, 10:30 PM
I am trying to associate a label with radcombobox like in this example.
http://www.telerik.com/help/aspnet-ajax/combo-associate-label.html

it's working but when i change the selected item it doesn't change in the radcombobx, the first item is always shown as the selected.
i tried this example also in an empty project and it doesn't work.


<asp:Label ID="Label1" runat="server"
   
Text="Select a country"
   
AssociatedControlID="RadComboBox1_Input">
</
asp:Label>
<
input type="hidden" id="RadComboBox1_Input"
   
runat="server"
   
style="display:none" />
<telerik:RadComboBox ID="RadComboBox1" runat="server">
   
<Items>
       
<telerik:RadComboBoxItem Text="USA" />
       
<telerik:RadComboBoxItem Text="Germany" />
       
<telerik:RadComboBoxItem Text="Canada" />
   
</Items>
</
telerik:RadComboBox>

The problem i think is the <input /> field

Thank you.

6 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 18 Dec 2009, 01:30 PM
Hi alexandrupaul,

Actually, you are right. It seems that the suggestion in this how-to article does not work well.
The good news is that we will implement a Label property for the RadComboBox in the future versions so you will not need to use such workaround.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
alexandrupaul
Top achievements
Rank 1
answered on 18 Dec 2009, 01:32 PM
it would be great :)

thank you
0
Pat
Top achievements
Rank 1
answered on 12 May 2010, 03:13 PM
Is there any way currently to use an asp:Label's AssociatedControlID property with a RADCombobox control?  I've seen how to do it for a RADTextbox by setting the for attribute of the Label in the codebehind to the RADInputID+"_text".  Is there something similar for that we can use for the RADCombobox?

We'd prefer to not use the label attribute of the RADCombobox as that doesn't allow us to have the label in a separate column from the control (so everything lines up nicely).

Any help would be greatly appreciated.  Thank you.
0
Kalina
Telerik team
answered on 14 May 2010, 12:27 PM
Hello Pat,

The AssociatedControlID property of the Label renders as “for" attribute and you can set its value to “RadComboBoxName_Input” in order to associate the Label to the RadComboBox input.

This can be done at OnClientLoad RadComboBox event handler:

<asp:Label ID="lblTest" runat="server"
AssociatedControlID="RadComboBox1">some text</asp:Label>
<telerik:RadComboBox ID="RadComboBox1" runat="server"
AccessibilityMode="true"
AppendDataBoundItems="true" DropDownWidth="300px"
Width="225px" OnClientLoad="OnClientLoadHandler" >
    <Items>
        <telerik:RadComboBoxItem Text="-- Select --" Value="-1" />
        <telerik:RadComboBoxItem Text="item 1" Value="1" />
        <telerik:RadComboBoxItem Text="item 2" Value="2" />
    </Items>
</telerik:RadComboBox>
 
<script type="text/javascript">
 
function OnClientLoadHandler(sender, eventArgs)
{
    var label = $telerik.$("#lblTest");
    label.attr({ "for": "RadComboBox1_Input", });
 
}
 
</script>


Best wishes,
Kalina
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Pat
Top achievements
Rank 1
answered on 14 May 2010, 01:27 PM

Hello Kalina,

 

Thanks for the response.  I see this looks rather simple, but it however doesn't allow any seem to all any sort of flexability for multiple label/combobox combinations on a single screen.  The is the case in many of our forms.  Do you have any ideas how you can make this more generic to work in a number of case?

Otherwise,  couldn't this be done from the code behind instead of using the AssociatedContolID in the markup?  For instance, couldn't the code behind be a one liner in the Page_Load that would say Label.attributes.add("for", Radcombobox.ClientID + "_Input");?

Thanks for the ideas so far.

0
Simon
Telerik team
answered on 14 May 2010, 01:30 PM
Hello Pat,

Yes, setting the attribute on the server in the way you gave as an example is completely fine.

Greetings,
Simon
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
alexandrupaul
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
alexandrupaul
Top achievements
Rank 1
Pat
Top achievements
Rank 1
Kalina
Telerik team
Simon
Telerik team
Share this question
or