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

RadListBox validation that items exist when used as a transfer destination

1 Answer 129 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 02 Apr 2013, 05:57 PM
I have a set of RadListBox es used to select categories. I want to validate that the transfer destination has items. I can get this to work but not when the control to validate is the RadListBox. Seems like I have to validate a text box to get  the Validator to fire client side. If the text box is not changed or is valid then the RadListBox does not get validated until the server side (which is better than never). Is it possible to get the Validator to fire another time even if it is just on the submit button? Here is the code:

Available Sub Categories<br />
<telerik:RadListBox ID="rlbAvailableSubcategories" runat="server" Height="200px"
    Width="200px" AllowTransfer="true" TransferToID="rlbMappedSubcategories" TransferMode="Copy"
    ButtonSettings-ShowTransferAll="false" SelectionMode="Multiple" AllowDelete="false" AllowTransferOnDoubleClick="True" ButtonSettings-TransferButtons="TransferFrom">
</telerik:RadListBox>
Mapped<br />
<telerik:RadListBox ID="rlbMappedSubcategories" runat="server" AllowTransferDuplicates="false"
    Height="200px" Width="200px" AllowDelete="true">
</telerik:RadListBox>
<asp:CustomValidator ID="ValidateMappedSubcategories" EnableClientScript="True" runat="server" ErrorMessage="You must add at least 1 category"
    ClientValidationFunction="rlbMappedSubcategoriesHasItems" ControlToValidate="txtAddLongDesc" ValidateEmptyText="True" OnServerValidate="rlbMappedSubcategoriesHasItems_Validate" Display="Dynamic"></asp:CustomValidator>
 
<script type="text/javascript">
    function rlbMappedSubcategoriesHasItems(source, args) {
        var list = $find("<%= rlbMappedSubcategories.ClientID %>");
        args.IsValid = list.get_items().get_count() > 0;
    }
</script>

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 05 Apr 2013, 08:57 AM
Hello Mike,

I tested the described scenario but the validation worked fine on my end. Please review the attached sample page and see if it works accordingly on your end. Could you also specify the version of the controls you are using, as well as the browser you're testing on.
 

Kind regards,
Bozhidar
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.
Tags
ListBox
Asked by
Mike
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or