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

How to clear item selection in Destination listbox when user selecting items in source listbox

1 Answer 287 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Santhosh asked on 11 May 2012, 04:42 PM
I am using 2 Radlistbox in my project for item transfer from source to destination list boxes and vice versa.
When user selecting item in soure listbox then automatically clear item selections in destination listbox.
i done it by using server side event OnSelectedIndexChanged of Radlistbox by adding RadlistboxSource.ClearSelection();
but how to do without OnSelectedIndexChanged event.

Please support.

Santhosh Naik

1 Answer, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 15 May 2012, 04:04 PM

You can clear the Source List Box and the Destination List Box by using client-side JavaScript functions as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<head runat="server">
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    <script language="javascript" type="text/javascript">
    functionClearDestinationListBoxOnSelectedIndexChanged(sender, args) {
        var listbox = $find("<%= RadListBoxDestination.ClientID %>");
     functionClearSourceListBoxOnSelectedIndexChanged(sender, args) {
         var listbox = $find("<%= RadListBoxSource.ClientID %>");
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <telerik:RadListBox runat="server" ID="RadListBoxSource" Height="200px" Width="230px"
            AllowTransfer="true" TransferToID="RadListBoxDestination" OnClientSelectedIndexChanged="ClearDestinationListBoxOnSelectedIndexChanged" >
            <telerik:RadListBoxItem Text="Argentina" />
            <telerik:RadListBoxItem Text="Australia" />
            <telerik:RadListBoxItem Text="Brazil" />
            <telerik:RadListBoxItem Text="Canada" />
            <telerik:RadListBoxItem Text="Chile" />
            <telerik:RadListBoxItem Text="China" />
            <telerik:RadListBoxItem Text="Egypt" />
            <telerik:RadListBoxItem Text="England" />
            <telerik:RadListBoxItem Text="France" />
            <telerik:RadListBoxItem Text="Germany" />
            <telerik:RadListBoxItem Text="India" />
            <telerik:RadListBoxItem Text="Indonesia" />
            <telerik:RadListBoxItem Text="Kenya" />
            <telerik:RadListBoxItem Text="Mexico" />
            <telerik:RadListBoxItem Text="New Zealand" />
            <telerik:RadListBoxItem Text="South Africa" />
            <telerik:RadListBoxItem Text="USA" />
        <telerik:RadListBox runat="server" ID="RadListBoxDestination" Height="200px" Width="200px" OnClientSelectedIndexChanged="ClearSourceListBoxOnSelectedIndexChanged" />
See the code in action at:

I hope this helps!
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Share this question