Class DualList

Provides the UI for the common requirement of two listboxes with items that move between them.

Inheritance
System.Object
DualList
Implements
System.Web.UI.INamingContainer
Namespace: Mediachase.Web.Console.Controls
Assembly: Mediachase.WebConsoleLib.dll
Version: 10.8.0
Syntax
public class DualList : WebControl, INamingContainer
Remarks

When DataBinding is used, the control will automaticly remove items from the left side if they exist on the right side. This ensures that double items can't be chosen.

For browsers that support scripting, the movement will be completely clientside. There is also 100% serverside support, for any browsers with script disabled or nonexistant.

By default, the clientscript used by the control is emited directly into the page. In order to save bandwidth, it's possible to have the control to use a script reference instead, but this requires the following handler to be added to the httpHandlers section of web.config.

<httpHandlers>
	<add verb="*"
		path="MetaBuilders_WebControls_DynamicListBoxResourceHandler.axd"
		type="MetaBuilders.WebControls.DynamicListBoxResourceHandler,MetaBuilders.WebControls.DynamicListBox"
		validate="false"
	/>
</httpHandlers>
Examples

The following is a simple example that uses this control.

<%@ Register TagPrefix="ecf" Namespace="Mediachase.WebConsoleLib.Controls" Assembly="Mediachase.WebConsoleLib" %>
<script runat="server" language="c#" >
	protected void DualList1_ItemsMoved( Object sender, EventArgs e ) {
		DualResult.Text = "The Chosen Items Are:";
		foreach( ListItem item in DualList1.RightBox.Items ) {
			DualResult.Text += "<br>" + item.Value + "/" + item.Text;
		}
	}
</script>
<form runat="server">
<ecf:DualList runat="server" Id="DualList1" OnItemsMoved="DualList1_ItemsMoved" >
	<LeftItems>
		<asp:ListItem Value="1" Text="One" />
		<asp:ListItem Value="2" Text="Two" />
		<asp:ListItem Value="3" Text="Three" />
	</LeftItems>
	<RightItems>
		<asp:ListItem Value="4" Text="Four" />
		<asp:ListItem Value="5" Text="Five" />
		<asp:ListItem Value="6" Text="Six" />
	</RightItems>
</ecf:DualList>
<br><br><asp:Label runat="server" id="DualResult" />
<hr><asp:Button runat="server" text="Smack"/>
</form>

Constructors

DualList()

Declaration
public DualList()

Properties

ButtonStyle

Gets the System.Web.UI.WebControls.WebControl.ControlStyle of the buttons contained in the control.

Declaration
public virtual Style ButtonStyle { get; }
Property Value
Type Description
System.Web.UI.WebControls.Style

The button style.

Controls

Overrides System.Web.UI.Control.Controls to implement the Composite Control Pattern

Declaration
public override ControlCollection Controls { get; }
Property Value
Type Description
System.Web.UI.ControlCollection

Enabled

Overrides System.Web.UI.WebControls.WebControl.Enabled

Declaration
public override bool Enabled { get; set; }
Property Value
Type Description
System.Boolean

EnableMoveAll

Gets or sets the visibility of the buttons for moving all items between the lists.

Declaration
public virtual bool EnableMoveAll { get; set; }
Property Value
Type Description
System.Boolean

true if [enable move all]; otherwise, false.

EnableMoveUpDown

Gets or sets the visibility of the buttons for moving items up and down within the list on the right side of the control.

Declaration
public virtual bool EnableMoveUpDown { get; set; }
Property Value
Type Description
System.Boolean

true if [enable move up down]; otherwise, false.

ItemsName

Gets or sets the text displayed above the lists, the plural name of the items being chosen.

Declaration
public virtual string ItemsName { get; set; }
Property Value
Type Description
System.String

The name of the items.

LeftDataMember

Gets or sets the DataMember of the list on the left side of the control.

Declaration
public virtual string LeftDataMember { get; set; }
Property Value
Type Description
System.String

The left data member.

LeftDataSource

Gets or sets the DataSource of the list on the left side of the control.

Declaration
public virtual object LeftDataSource { get; set; }
Property Value
Type Description
System.Object

The left data source.

LeftDataTextField

Gets or sets the DataTextField of the list on the left side of the control.

Declaration
public virtual string LeftDataTextField { get; set; }
Property Value
Type Description
System.String

The left data text field.

LeftDataTextFormatString

Gets or sets the DataTextFormatString of the list on the left side of the control.

Declaration
public virtual string LeftDataTextFormatString { get; set; }
Property Value
Type Description
System.String

The left data text format string.

LeftDataValueField

Gets or sets the DataValueField of the list on the left side of the control.

Declaration
public virtual string LeftDataValueField { get; set; }
Property Value
Type Description
System.String

The left data value field.

LeftItems

Gets the items in the list the left side of the control.

Declaration
public virtual ListItemCollection LeftItems { get; }
Property Value
Type Description
System.Web.UI.WebControls.ListItemCollection

The left items.

LeftListStyle

Gets the System.Web.UI.WebControls.WebControl.ControlStyle of the list on left side of the control.

Declaration
public virtual Style LeftListStyle { get; }
Property Value
Type Description
System.Web.UI.WebControls.Style

The left list style.

ListRows

Gets or sets the number of rows visible in the lists of the control.

Declaration
public virtual int ListRows { get; set; }
Property Value
Type Description
System.Int32

The list rows.

RightDataMember

Gets or sets the DataMember of the list on the right side of the control.

Declaration
public virtual string RightDataMember { get; set; }
Property Value
Type Description
System.String

The right data member.

RightDataSource

Gets or sets the DataSource of the list on the right side of the control.

Declaration
public virtual object RightDataSource { get; set; }
Property Value
Type Description
System.Object

The right data source.

RightDataTextField

Gets or sets the DataTextField of the list on the right side of the control.

Declaration
public virtual string RightDataTextField { get; set; }
Property Value
Type Description
System.String

The right data text field.

RightDataTextFormatString

Gets or sets the DataTextFormatString of the list on the right side of the control.

Declaration
public virtual string RightDataTextFormatString { get; set; }
Property Value
Type Description
System.String

The right data text format string.

RightDataValueField

Gets or sets the DataValueField of the list on the right side of the control.

Declaration
public virtual string RightDataValueField { get; set; }
Property Value
Type Description
System.String

The right data value field.

RightItems

Gets the items in the list the right side of the control.

Declaration
public virtual ListItemCollection RightItems { get; }
Property Value
Type Description
System.Web.UI.WebControls.ListItemCollection

The right items.

RightListStyle

Gets the System.Web.UI.WebControls.WebControl.ControlStyle of the list on right side of the control.

Declaration
public virtual Style RightListStyle { get; }
Property Value
Type Description
System.Web.UI.WebControls.Style

The right list style.

TagKey

Overrides System.Web.UI.WebControls.WebControl.TagKey

Declaration
protected override HtmlTextWriterTag TagKey { get; }
Property Value
Type Description
System.Web.UI.HtmlTextWriterTag

Methods

CreateChildControls()

Overrides System.Web.UI.Control.CreateChildControls to implement the Composite Control Pattern

Declaration
protected override void CreateChildControls()

CreateControlStyle()

Overrides System.Web.UI.WebControls.WebControl.CreateControlStyle.

Declaration
protected override Style CreateControlStyle()
Returns
Type Description
System.Web.UI.WebControls.Style

A System.Web.UI.WebControls.Style that is used to implement all style-related properties of the control.

DataBind()

Overrides System.Web.UI.Control.DataBind.

Declaration
public override void DataBind()

FixAvailableItems()

FixAvailableItems is called after DataBind() to make sure that none of the items on the right, "chosen", list exist in the left, "available" list.

Declaration
protected virtual void FixAvailableItems()

OnItemsMoved(EventArgs)

Raises the ItemsMoved event.

Declaration
protected virtual void OnItemsMoved(EventArgs e)
Parameters
Type Name Description
System.EventArgs e

The System.EventArgs instance containing the event data.

OnPreRender(EventArgs)

Overrides System.Web.UI.Control.OnPreRender(System.EventArgs).

Declaration
protected override void OnPreRender(EventArgs e)
Parameters
Type Name Description
System.EventArgs e

An System.EventArgs object that contains the event data.

RegisterScript()

Registers the script for this control.

Declaration
protected virtual void RegisterScript()

RegisterScriptArray()

Registers the script array for this control.

Declaration
protected virtual void RegisterScriptArray()

RegisterScriptLibrary()

Registers the script library for this control.

Declaration
protected virtual void RegisterScriptLibrary()

RegisterScriptStartup()

Registers the script which initializes this control.

Declaration
protected virtual void RegisterScriptStartup()

Render(HtmlTextWriter)

Overrides System.Web.UI.Control.Render(System.Web.UI.HtmlTextWriter).

Declaration
protected override void Render(HtmlTextWriter writer)
Parameters
Type Name Description
System.Web.UI.HtmlTextWriter writer

The System.Web.UI.HtmlTextWriter object that receives the control content.

Events

ItemsMoved

The event that fires when items have been moved.

Declaration
public event EventHandler ItemsMoved
Event Type
Type Description
System.EventHandler

Implements

System.Web.UI.INamingContainer