Prevent Deletion of RadListBoxItem

2 posts, 0 answers
  1. G.
    G. avatar
    10 posts
    Member since:
    Oct 2011

    Posted 20 Jan 2012 Link to this post


    Telerik.Web.UI Version 2010.3.1317.35

    I have 2 RadListBox controls defined as follows:



    <div id="dFieldSelection" style="padding:5px;" runat="server">




    <telerik:radlistbox runat="server" DataTextField="Name" DataValueField="FieldID" ID="radListBox_1" AllowDelete="True"




    AllowReorder="True" AllowTransfer="True" AutoPostBackOnTransfer="true" AutoPostBackOnDelete="true" TransferToID="radListBox_2">








    <telerik:radlistbox runat="server" ID="radListBox_2"




    AutoPostBackOnTransfer="true" AutoPostBackOnDelete="true"









    I programmtically place some mandatory fields into radListBox_2...  my goal is to prevent a user from deleting these mandatory items from radListBox_2 (i.e. I have noticed that the radListBox_2_Deleting server side event get executed when the user presses the arrow button to transfer an item back to radListBox_1).

    Inside of radListBox_2_Deleting server side event I simply do some code checks and if this is a mandtory item I set e.Cancel = true... hoping that that will cancel the deletion.  However, this does not appear to work as I expected.

    How can I prevent a user from moving 1 RadListBoxItem from radListBox_2 back into radListBox_1?

    Thx in advance!!!


  2. Bozhidar
    Bozhidar avatar
    1095 posts

    Posted 23 Jan 2012 Link to this post

    Hello Gerald,

    You can use the OnClientTransferring event and check if the source listbox is the one you don't want to delete from. If it is, then you can use args.set_cancel(true) to cancel the transfer. Here's an example:
    function clientTransferring(sender, args) {
        var listbox = $find("<%= radListBox_2.ClientID %>");
        if(args.get_sourceListBox() == listbox)

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. DevCraft R3 2016 release webinar banner
Back to Top