iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
!!! Design for user control <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucMembership.ascx.vb" Inherits="MembershipTest.ucMembership" %> <%@ Register Assembly="ISNet.WebUI.WebEssentials" Namespace="ISNet.WebUI.WebEssentials" TagPrefix="ISWebEssentials" %> <asp:Table ID="tblMembership" runat="server"> <asp:TableRow> <asp:TableCell RowSpan="4"> <ISWebEssentials:WebListBox ID="wlbAvailableItems" runat=server Width="45%" Height="100%" SelectedIndex="-1" SelectionMode="Multiple" DefaultStyleMode="Win7" EnableKeyboardSupport="true"> <LayoutSettings ItemHeight="20" ScrollMode="ScrollBar" /> </ISWebEssentials:WebListBox> </asp:TableCell> <asp:TableCell> <asp:Button ID="btnMoveRight" runat="server" Text =">" Width="30px" /> </asp:TableCell> <asp:TableCell RowSpan="4"> <ISWebEssentials:WebListBox ID="wlbSelectedItems" runat=server Width="45%" Height="100%" SelectedIndex="-1" SelectionMode="Multiple" DefaultStyleMode="Win7" EnableKeyboardSupport="true"> <LayoutSettings ItemHeight="20" ScrollMode="ScrollBar" /> </ISWebEssentials:WebListBox> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Button ID="btnMoveAllRight" runat="server" Text =">>" Width="30px" /> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Button ID="btnMoveLeft" runat="server" Text ="<" Width="30px" /> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell> <asp:Button ID="btnMoveAllLeft" runat="server" Text ="<<" Width="30px" /> </asp:TableCell> </asp:TableRow> </asp:Table> !!! Code behind for user control Imports ISNet.WebUI.WebEssentials Public Class ucMembership Inherits System.Web.UI.UserControl Public Property ControlHeight() As Double Get Return CType(ViewState("ControlHeight"), Double) End Get Set(ByVal value As Double) ViewState("ControlHeight") = value End Set End Property Public Property ControlWidth() As Double Get Return CType(ViewState("ControlWidth"), Double) End Get Set(ByVal value As Double) ViewState("ControlWidth") = value End Set End Property Public Property DefaultStyleMode() As WebListBoxDefaultStyleMode Get Return CType(ViewState("DefaultStyleMode"), WebListBoxDefaultStyleMode) End Get Set(value As WebListBoxDefaultStyleMode) ViewState("DefaultStyleMode") = value End Set End Property Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then If ControlHeight.ToString <> "" Then tblMembership.Height = New System.Web.UI.WebControls.Unit(ControlHeight, UnitType.Pixel) wlbAvailableItems.Height = New System.Web.UI.WebControls.Unit(ControlHeight, UnitType.Pixel) wlbSelectedItems.Height = New System.Web.UI.WebControls.Unit(ControlHeight, UnitType.Pixel) End If If ControlWidth.ToString <> "" Then tblMembership.Width = New System.Web.UI.WebControls.Unit(ControlWidth, UnitType.Pixel) wlbAvailableItems.Width = New System.Web.UI.WebControls.Unit(ControlWidth * 0.45, UnitType.Pixel) wlbSelectedItems.Width = New System.Web.UI.WebControls.Unit(ControlWidth * 0.45, UnitType.Pixel) End If If DefaultStyleMode.ToString <> "" Then wlbAvailableItems.DefaultStyleMode = DefaultStyleMode wlbSelectedItems.DefaultStyleMode = DefaultStyleMode End If End If End Sub Public Sub SetAvailableItems(ByVal ItemList As Collection) Dim x As WebListBoxItem Dim ListItem As ListItem wlbAvailableItems.Items.Clear() For Each ListItem In ItemList x = New WebListBoxItem x.Text = ListItem.Text x.Value = ListItem.Value wlbAvailableItems.Items.Add(x) Next End Sub Public Sub SetSelectedItems(ByVal ItemList As Collection) Dim x As WebListBoxItem Dim ListItem As ListItem wlbSelectedItems.Items.Clear() For Each ListItem In ItemList x = New WebListBoxItem x.Text = ListItem.Text x.Value = ListItem.Value wlbSelectedItems.Items.Add(x) Next End Sub Private Sub btnMoveRight_Click(sender As Object, e As EventArgs) Handles btnMoveRight.Click Dim ListItem As WebListBoxItem Dim SelectedItems As List(Of String) Dim SelectedValue As String Dim i As Integer Dim Moved As Boolean SelectedItems = wlbAvailableItems.GetValues() For Each SelectedValue In SelectedItems For Each ListItem In wlbAvailableItems.Items If ListItem.Value.ToLower = SelectedValue.ToLower Then wlbSelectedItems.Items.Add(ListItem) Exit For End If Next Next wlbAvailableItems.SetValues(New List(Of String)) 'try clearing all items wlbAvailableItems.Items.Clear() 'try recreating client controls 'wlbAvailableItems.RecreateChildControls() 'try building a copy of the items and then adding them in after a clear 'Dim AvailableListItems(wlbAvailableItems.Items.Count) As WebListBoxItem 'wlbAvailableItems.Items.CopyTo(AvailableListItems, 0) 'wlbAvailableItems.Items.Clear() 'For i = LBound(AvailableListItems) To UBound(AvailableListItems) - 1 ' Moved = False ' For Each SelectedValue In SelectedItems ' If AvailableListItems(i).Value.ToLower = SelectedValue.ToLower Then ' Moved = True ' Exit For ' End If ' Next ' If Not Moved Then ' wlbAvailableItems.Items.Add(AvailableListItems(i)) ' End If 'Next End Sub End Class !!! Design page that calls user control <div style="position: absolute; top:35px; left: 19px; height: 100px; width: 200px;"> <uc1:ucMembership ID="ucMembership1" runat="server" ControlHeight="100" ControlWidth="400" DefaultStyleMode="OutlookBlue" /> </div> !!! Code behind page for call to the user control Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim x As New Collection Dim y As New ListItem Dim i As Integer For i = 1 To 10 y = New ListItem y.Text = "test " + i.ToString y.Value = i x.Add(y) Next ucMembership1.SetAvailableItems(x) x = New Collection For i = 11 To 13 y = New ListItem y.Text = "test " + i.ToString y.Value = i x.Add(y) Next ucMembership1.SetSelectedItems(x) End If End Sub End Class
When I run the program I get items 1 through 10 in the Available Items list and items 11 to 13 in the Selected Items list. If I choose the first 3 items of the Available List and click the Move Right button (top one) the page crashes with the attached error. NOTE: There is commented code in the user control that tries to clear the items. You have to uncomment some of that to see the error.
Is there a way to remove items from a WebListBox without invoking a page crash?
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname