ClearSelection method undefined

2 posts, 0 answers
  1. Guillaume
    Guillaume avatar
    15 posts
    Member since:
    Oct 2010

    Posted 27 Jan 2014 Link to this post

    Hi,

    I am trying to reset the value set in a combobox of a ComboBox used in a UserControl.

    UserControl looks like that :

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserControl.ascx.cs" Inherits="UserControls.UserControl" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
        <telerik:RadComboBox ID="comboBox" runat="server" 
        EnableVirtualScrolling="false" EnableTextSelection="true" MaxHeight="250px" 
        AllowCustomText="False" MarkFirstMatch="false" ShowMoreResultsBox="true" 
        Filter="Contains" EnableLoadOnDemand="True" Sort="Ascending" Width="280px" 
        OnItemsRequested="comboBox_ItemsRequested" AutoPostBack="True" 
        OnSelectedIndexChanged="comboBox_SelectedIndexChanged" CausesValidation="false" 
        ZIndex="1000" ontextchanged="comboBox_TextChanged"></telerik:RadComboBox>
    </span>


    When I try to call the ClearSelection of the comboBox in default.aspx like that :

    <html>
    <body onload="Load()" >
    <uc1:UserControl ID="cboComboBox" runat="server" Width="95%" MaxHeight="175px" />
    </body>
    </html>
    <script type="text/javascript">
        function Load() {
            var cboComboBox= document.getElementById('<%=cboComboBox.FindControl("comboBox").ClientID%>');
            cboComboBox.clearSelection();
        }
    </script>

    I keep getting the error "Method undefined"

    Any idea why ?

    Thanks,

    Guillaume


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Jan 2014 in reply to Guillaume Link to this post

    Hi,

    Please try the following JavaScript which works fine at my end.

    JavaScript:
    <script type="text/javascript">
     function Load() {
       var cboComboBox =document.getElementById('<%=cboComboBox.FindControl("comboBox").ClientID%>');
       cboComboBox.control.clearSelection();
     }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top