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

ClearSelection method undefined

1 Answer 67 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Guillaume
Top achievements
Rank 1
Guillaume asked on 27 Jan 2014, 10:06 PM
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


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Jan 2014, 03:37 AM
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.
Tags
ComboBox
Asked by
Guillaume
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or