|
| 1 | +--- |
| 2 | +title: Resolving Incorrect ARIA Attribute Value in RadComboBox with Load-on-Demand |
| 3 | +description: This article provides a solution to the ARIA attribute value issue in RadComboBox with Load-on-Demand functionality, ensuring WAI-ARIA compliance. |
| 4 | +type: troubleshooting |
| 5 | +page_title: Fix ARIA Attribute Value Error in RadComboBox for ASP.NET AJAX |
| 6 | +slug: combobox-aria-attribute-value-error |
| 7 | +tags: dropdown, combobox, web forms, asp.net ajax, aria, load-on-demand, accessibility, wai-aria |
| 8 | +res_type: kb |
| 9 | +ticketid: 1667614 |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | + |
| 14 | +<table> |
| 15 | +<tbody> |
| 16 | +<tr> |
| 17 | +<td>Product</td> |
| 18 | +<td>RadComboBox for ASP.NET AJAX</td> |
| 19 | +</tr> |
| 20 | +<tr> |
| 21 | +<td>Version</td> |
| 22 | +<td>2024.3.805</td> |
| 23 | +</tr> |
| 24 | +</tbody> |
| 25 | +</table> |
| 26 | + |
| 27 | +## Description |
| 28 | +When using the [RadComboBox](https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/overview) with `EnableLoadOnDemand="true"` and subscribing to the `OnItemsRequested` event, an error notification from ARC Toolkit Chrome add-on indicates an error: `ARIA attribute value is incorrect`. This issue occurs on the first load when the listbox is not pre-loaded. However, after the listbox is displayed, the error does not recur. |
| 29 | + |
| 30 | +## Cause |
| 31 | +The problem stems from the `Load-on-Demand` functionality, where the dropdown list is not initially rendered. Consequently, the `aria-controls` attribute references an ID for a component that does not exist at the moment, leading to the error. |
| 32 | + |
| 33 | +## Solution |
| 34 | +To fix this issue, dynamically set the `id` attribute for the listbox in the `OnClientLoad` event and remove it in the `OnClientDropDownOpened` event. This approach ensures effective management of the `aria-controls` attribute, aligning it with the `Load-on-Demand` behavior and maintaining WAI-ARIA compliance. |
| 35 | + |
| 36 | +```aspx |
| 37 | +<telerik:RadComboBox ID="RadComboBox1" runat="server" RenderMode="Lightweight" |
| 38 | + EnableAriaSupport="true" |
| 39 | + AllowCustomText="true" |
| 40 | + CausesValidation="false" |
| 41 | + EnableLoadOnDemand="true" OnItemsRequested="RadComboBox1_ItemsRequested" |
| 42 | + OnClientLoad="OnClientLoad" |
| 43 | + OnClientDropDownOpened="OnClientDropDownOpened" |
| 44 | + EmptyMessage="RadComboBox1 Empty Message"> |
| 45 | +</telerik:RadComboBox> |
| 46 | +
|
| 47 | +<script> |
| 48 | + function OnClientLoad(sender, args) { |
| 49 | + var listboxId = sender.get_id() + "_listbox"; |
| 50 | + $telerik.$(".rcbSlide").attr("id", listboxId); |
| 51 | + } |
| 52 | +
|
| 53 | + function OnClientDropDownOpened(sender, args) { |
| 54 | + var listboxId = sender.get_id() + "_listbox"; |
| 55 | + $telerik.$(".rcbSlide").removeAttr("id"); |
| 56 | + } |
| 57 | +</script> |
| 58 | +``` |
| 59 | +```C# |
| 60 | +protected void RadComboBox1_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) |
| 61 | +{ |
| 62 | + RadComboBox combo = sender as RadComboBox; |
| 63 | + combo.Items.Add(new RadComboBoxItem("Item1", "1")); |
| 64 | + combo.Items.Add(new RadComboBoxItem("Item2", "2")); |
| 65 | + combo.Items.Add(new RadComboBoxItem("Item3", "3")); |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +This solution ensures the `aria-controls` attribute correctly references the listbox when it becomes available, preventing accessibility issues related to non-existent IDs. |
| 70 | + |
| 71 | +## See Also |
| 72 | +- [RadComboBox Overview](https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/overview) |
| 73 | +- [WAI-ARIA Basics](https://www.w3.org/WAI/standards-guidelines/aria/) |
| 74 | + |
0 commit comments