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
>