RadListBox validation that items exist when used as a transfer destination

2 posts, 0 answers
  1. Mike
    Mike avatar
    1 posts
    Member since:
    Apr 2013

    Posted 02 Apr 2013 Link to this post

    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>
  2. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 05 Apr 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top