Thanks Shinu. I just spend 2 hours with the same problem, your post got me straight! Thank you PJ for taking the time to post it in the first place also.
Hello Justin,
You could toggle the display CSS property of its container between "none" and an empty string.
The following works fine for me, though:
<telerik:RadComboBox ID=
"RadComboBox1"
runat=
"server"
OnClientSelectedIndexChanged=
"OnClientSelectedIndexChanged"
>
<Items>
<telerik:RadComboBoxItem Text=
" item1"
/>
<telerik:RadComboBoxItem Text=
" item2"
/>
</Items>
</telerik:RadComboBox>
<telerik:RadComboBox ID=
"RadComboBox2"
runat=
"server"
>
</telerik:RadComboBox>
<script type=
"text/javascript"
>
function
pageLoad() {
var
combo = $find(
"<%= RadComboBox2.ClientID %>"
);
combo.set_visible(
false
);
// Hide the Combo when page loads
function
OnClientSelectedIndexChanged() {
var
combo = $find(
"<%= RadComboBox2.ClientID %>"
);
combo.set_visible(
true
);
var
comboItem =
new
Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text(
"New Item"
);
combo.trackChanges();
combo.get_items().add(comboItem);
comboItem.select();
combo.commitChanges();
</script>
So if it doesn't work for you or your case is different, can you modify this sample to showcase the issue? Also, can you confirm you are using the latest version of the UI for ASP.NET AJAX controls?
Also, if you are looking to populate a combo box on demand, it offers such features out of the box:
https://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx
. You can trigger loading of items through its client-side API as well, see the .requestItems(text, shouldAppend) method and Example 4:
https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/client-side-programming/objects/radcombobox-object
.
Regards,
Marin Bratanov
Progress Telerik
Get
q
uickly onboarded and successful
with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.
Learn More
.
Hi Shubham,
Then you will need to write some logic in the
OnClientSelectedIndexChanged handler
that determines whether to hide or not the other control.
Regards,
Marin Bratanov
Progress Telerik
Get
q
uickly onboarded and successful
with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.
Learn More
.