Hi Guys,
I haven't had the need to use much javascript...so please forgive my ignorance.
Im trying to write some client-side validation code.
The premise is that each listbox item hold a delimited value that contains a ProductId and other ProductIds it cannot coexist with.
For example value=1,4,6,8. This is intrepreted that the ProductId of this item =1 and it cannot be added to any list box which already has Products 4,6 or 8 in it.
I have successfully done this server side with the following code and I am trying to reproduce client-side with javascript. Any help would be appreciated.
Private Sub RadListBoxDestination_Transferring(sender As Object, e As Telerik.Web.UI.RadListBoxTransferringEventArgs) Handles RadListBoxDestination.Transferring Dim aryNoCoExist As Array Dim i As Integer Dim Product As Integer Dim Cancel As Boolean = False Dim BoxItem As Telerik.Web.UI.RadListBoxItem Dim NoCoExist As String = "" Me.ErrorLabel.Text = "" If RadListBoxDestination.Items.Count > 0 Then Product = GetProductId(e.Items(0).Value) 'GetProductId returns the first delimited string item For Each BoxItem In RadListBoxDestination.Items If Len(NoCoExist) Then NoCoExist = NoCoExist & "," & GetNoCoExist(BoxItem.Value) 'GetNoCoExist returns the remaining delimited string minus the first item Else NoCoExist = GetNoCoExist(BoxItem.Value) End If Next aryNoCoExist = Split(NoCoExist, ",") For i = 0 To aryNoCoExist.GetUpperBound(0) If Product = aryNoCoExist(i) Then Cancel = True Me.ErrorLabel.Text = "Product Not Compatible with Existing Selections" End If Next e.Cancel = Cancel End IfEnd SubMy Listbox Definition:
<telerik:RadListBox runat="server" ID="RadListBoxSource" Height="200px" Width="300px" AllowTransfer="true" TransferToID="RadListBoxDestination" AllowTransferOnDoubleClick="True" EnableDragAndDrop="True"> <ButtonSettings TransferButtons="Common" ShowDelete="False" ShowReorder="False" ShowTransferAll="False"></ButtonSettings> </telerik:RadListBox> <telerik:RadListBox ID="RadListBoxDestination" runat="server" Height="200px" Width="300px" AllowTransfer="true" TransferToID="RadListBoxSource" AllowTransferOnDoubleClick="True" EnableDragAndDrop="True" OnClientTransferring="onTransferring"> <ButtonSettings TransferButtons="Common" ShowTransfer="false" ShowDelete="False" ShowReorder="False" ShowTransferAll="False"></ButtonSettings> </telerik:RadListBox>
Thanks....
David