using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.Design;
using System.Drawing.Design;
using System.Drawing;
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace RD.WebControls
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
[DefaultProperty("LeftListDataTextField")]
[ToolboxData("<{0}:TwoListBox runat=server></{0}:TwoListBox>")]
public class TwoListBox : CompositeControl
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
Private Member#region Private Member
private ListBox m_LeftListBox;
private ListBox m_RightListBox;
private System.Web.UI.WebControls.Image m_ImageRemoveLeft;
private System.Web.UI.WebControls.Image m_ImageRemoveRight;
private System.Web.UI.WebControls.Image m_ImageRemoveAllLeft;
private System.Web.UI.WebControls.Image m_ImageRemoveAllRight;
private System.Web.UI.WebControls.Image m_ImageRemoveUp;
private System.Web.UI.WebControls.Image m_ImageRemoveDown;
private System.Web.UI.WebControls.Image m_ImageRemoveTop;
private System.Web.UI.WebControls.Image m_ImageRemoveBottom;
private System.Web.UI.WebControls.Label m_LeftLable;
private System.Web.UI.WebControls.Label m_RightLable;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private TextBox m_LeftHiddenTextBox;
private TextBox m_RightHiddenTextBox;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private string strLeftImageUrl=string.Empty ;
private string strLeftssImageUrl=string.Empty;
private string strRightImageUrl = string.Empty;
private string strRightssImageUrl = string.Empty;
private string strUpImageUrl = string.Empty;
private string strDownImageUrl = string.Empty;
private string strTopImageUrl = string.Empty;
private string strBottomImageUrl = string.Empty;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
Public property#region Public property
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[DefaultValue("LeftListTitle"), Category("TwoListBox"), Description("左邊文字方塊Text"), Localizable(true)]
public string LeftListTitle
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "LeftListTitle"];
return (obj == null) ? "LeftListTitle" : (string)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "LeftListTitle"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[DefaultValue("RightListTitle"), Category("TwoListBox"), Description("右邊文字方塊Text"), Localizable(true)]
public string RightListTitle
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "RightListTitle"];
return (obj == null) ? "RightListTitle" : (string)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "RightListTitle"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[DefaultValue(100), Category("TwoListBox"), Description("ListBox寬度"), Localizable(true)]
public Unit ListBoxWidth
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "ListBoxWidth"];
return (obj == null) ? 100 : (Unit)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "ListBoxWidth"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("ListBox高度"), Localizable(true)]
public Unit ListBoxHeight
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "ListBoxHeight"];
return (obj == null) ? Unit.Empty : (Unit)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "ListBoxHeight"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("ListBox是否允許多選"), Localizable(true)]
public ListSelectionMode SelectionMode
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "SelectionMode"];
return (obj == null) ? ListSelectionMode.Single : (ListSelectionMode)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "SelectionMode"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("右邊所有移動圖片按鈕是否可見"), Localizable(true)]
public bool IsRightImageVisable
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "IsRightImageVisable"];
return (obj == null) ? true : (bool)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IsRightImageVisable"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("左邊ListBox的DataValueField"), Localizable(true)]
public string LeftListDataValueField
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = this.ViewState["LeftListDataValueField"];
return (obj == null) ? string.Empty : (string)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.ViewState["LeftListDataValueField"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("左邊ListBox的DataTextField"), Localizable(true)]
public string LeftListDataTextField
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = this.ViewState["LeftListDataTextField"];
return (obj == null) ? string.Empty : (string)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.ViewState["LeftListDataTextField"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("右邊ListBox的DataValueField"), Localizable(true)]
public string RightListDataValueField
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = this.ViewState["RightListDataValueField"];
return (obj == null) ? string.Empty : (string)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
this.ViewState["RightListDataValueField"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("右邊ListBox的DataTextField"), Localizable(true)]
public string RightListDataTextField
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = this.ViewState["RightListDataTextField"];
return (obj == null) ? string.Empty : (string)obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
this.ViewState["RightListDataTextField"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("LeftListBox資料源"), Localizable(true), Browsable(false)]
public object LeftListDataSource
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "LeftListDataSource"];
return (obj == null) ? null : obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
ViewState[ClientID + "LeftListDataSource"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("RightListBox資料源"), Localizable(true), Browsable(false)]
public object RightListDataSource
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
object obj = ViewState[ClientID + "RightListDataSource"];
return (obj == null) ? null : obj;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
ViewState[ClientID + "RightListDataSource"] = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("LeftListBox資料集合"), Localizable(true), Browsable(false)]
public ListItemCollection LeftListBoxItems
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
return (m_LeftListBox==null) ? null: m_LeftListBox.Items;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Description("RightListBox資料集合"), Localizable(true), Browsable(false)]
public ListItemCollection RightListBoxItems
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
return (m_RightListBox == null) ? null : m_RightListBox.Items;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("左移按鈕圖片URl")]
public string IamgeUrlLeft
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlLeft"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlLeft"] = value;
strLeftImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("右移按鈕圖片URl")]
public string IamgeUrlRight
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlRight"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlRight"] = value;
strRightImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("左移全部按鈕圖片URl")]
public string IamgeUrlLeftss
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlLeftss"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlLeftss"] = value;
strLeftssImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("右移全部按鈕圖片URl")]
public string IamgeUrlRightss
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlRightss"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlRightss"] = value;
strRightImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("上移按鈕圖片URl")]
public string IamgeUrlUp
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlLeftUp"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlLeftUp"] = value;
strUpImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("下移按鈕圖片URl")]
public string IamgeUrlDown
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlDown"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlDown"] = value;
strDownImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("上移到頂全部按鈕圖片URl")]
public string IamgeUrlTop
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlTop"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlTop"] = value;
strTopImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Category("TwoListBox"), Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), DefaultValue(""), UrlProperty, Bindable(true), Description("下移到底全部按鈕圖片URl")]
public string IamgeUrlBottom
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
get
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string text = (string)this.ViewState[ClientID + "IamgeUrlBottom"];
if (text != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return text;
}
return string.Empty;
}
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
ViewState[ClientID + "IamgeUrlBottom"] = value;
strBottomImageUrl = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
Override Function#region Override Function
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected override void OnInit(EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (this.Page != null)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Page.ClientScript.RegisterClientScriptResource(this.GetType(), "RD.WebControls.TwoListBox.TwoListBox.js");
base.OnInit(e);
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected override void OnLoad(EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
base.OnLoad(e);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (Page.IsPostBack)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string strLeftTextValue = m_LeftHiddenTextBox.Text;
string strRightTextValue = m_RightHiddenTextBox.Text;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
LeftListDataSource = ConcertHiddenTextBoxToTable(strLeftTextValue, LeftListDataTextField, LeftListDataValueField);
RightListDataSource = ConcertHiddenTextBoxToTable(strRightTextValue,RightListDataTextField, RightListDataValueField);
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
DataBindLeftListBox();
DataBindRightListBox();
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected override void RecreateChildControls()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected override void CreateChildControls()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Controls.Clear();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
m_LeftListBox = new ListBox();
m_LeftListBox.ID = "LeftListBox";
m_RightListBox = new ListBox();
m_RightListBox.ID = "RightListBox";
m_ImageRemoveLeft = new System.Web.UI.WebControls.Image();
m_ImageRemoveLeft.ID = "ImageRemoveLeft";
m_ImageRemoveRight = new System.Web.UI.WebControls.Image();
m_ImageRemoveRight.ID = "ImageRemoveRight";
m_ImageRemoveAllLeft = new System.Web.UI.WebControls.Image();
m_ImageRemoveAllLeft.ID = "ImageRemoveAllLeft";
m_ImageRemoveAllRight = new System.Web.UI.WebControls.Image();
m_ImageRemoveAllRight.ID = "ImageRemoveAllRight";
m_ImageRemoveUp = new System.Web.UI.WebControls.Image();
m_ImageRemoveUp.ID = "ImageRemoveUp";
m_ImageRemoveDown = new System.Web.UI.WebControls.Image();
m_ImageRemoveDown.ID = "ImageRemoveDown";
m_ImageRemoveTop = new System.Web.UI.WebControls.Image();
m_ImageRemoveTop.ID = "ImageRemoveTop";
m_ImageRemoveBottom = new System.Web.UI.WebControls.Image();
m_ImageRemoveBottom.ID = "ImageRemoveBottom";
m_LeftLable = new Label();
m_LeftLable.ID = "LeftLable";
m_RightLable = new Label();
m_RightLable.ID = "RightLable";
m_LeftHiddenTextBox = new TextBox();
m_LeftHiddenTextBox.ID = "LeftHiddenTextBox";
m_RightHiddenTextBox = new TextBox();
m_RightHiddenTextBox.ID = "RightHiddenTextBox";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.Controls.Add(m_LeftListBox);
this.Controls.Add(m_RightListBox);
this.Controls.Add(m_ImageRemoveLeft);
this.Controls.Add(m_ImageRemoveRight);
this.Controls.Add(m_ImageRemoveAllLeft);
this.Controls.Add(m_ImageRemoveAllRight);
this.Controls.Add(m_ImageRemoveUp);
this.Controls.Add(m_ImageRemoveDown);
this.Controls.Add(m_ImageRemoveTop);
this.Controls.Add(m_ImageRemoveBottom);
this.Controls.Add(m_LeftLable);
this.Controls.Add(m_RightLable);
this.Controls.Add(m_LeftHiddenTextBox);
this.Controls.Add(m_RightHiddenTextBox);
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected override void Render(HtmlTextWriter writer)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
EnsureChildControls();
SetProptyToRender();
AddAttributesToRender(writer);
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0px");
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0px");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_LeftLable.RenderControl(writer);
writer.RenderEndTag(); // Td
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_LeftHiddenTextBox.RenderControl(writer);
writer.RenderEndTag(); // Td
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_RightLable.RenderControl(writer);
writer.RenderEndTag(); // Td
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_RightHiddenTextBox.RenderControl(writer);
writer.RenderEndTag(); // Td
writer.RenderEndTag(); // Tr
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "4");
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_LeftListBox.RenderControl(writer);
writer.RenderEndTag(); // Td
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveRight.RenderControl(writer);
writer.RenderEndTag(); // Td
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "4");
if (IsRightImageVisable)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_RightListBox.RenderControl(writer);
writer.RenderEndTag(); // Td
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveTop.RenderControl(writer);
writer.RenderEndTag(); // Td
}
else
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_RightListBox.RenderControl(writer);
writer.RenderEndTag(); // Td
}
writer.RenderEndTag(); // Tr
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveAllRight.RenderControl(writer);
writer.RenderEndTag(); // Td
if (IsRightImageVisable)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveUp.RenderControl(writer);
writer.RenderEndTag(); // Td
}
writer.RenderEndTag(); // Tr
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveAllLeft.RenderControl(writer);
writer.RenderEndTag(); // Td
if (IsRightImageVisable)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveDown.RenderControl(writer);
writer.RenderEndTag(); // Td
}
writer.RenderEndTag(); // Tr
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveLeft.RenderControl(writer);
writer.RenderEndTag(); // Td
if (IsRightImageVisable)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
m_ImageRemoveBottom.RenderControl(writer);
writer.RenderEndTag(); // Td
}
writer.RenderEndTag(); // Tr
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
writer.RenderEndTag(); // Table
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
Public Function#region Public Function
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
Private Function#region Private Function
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 在Render之前為子控件添加屬性
/// </summary>
private void SetProptyToRender()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
m_LeftLable.Text = LeftListTitle;
m_RightLable.Text = RightListTitle;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
m_LeftHiddenTextBox.Width = 0;
m_RightHiddenTextBox.Width = 0;
m_LeftHiddenTextBox.Style.Add("display", "none");
m_RightHiddenTextBox.Style.Add("display", "none");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (IamgeUrlLeft.Length == 0)
strLeftImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.left.gif");
if (IamgeUrlLeftss.Length == 0)
strLeftssImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.leftss.gif");
if (IamgeUrlRight.Length == 0)
strRightImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.right.gif");
if (IamgeUrlRightss.Length == 0)
strRightssImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.rightss.gif");
if (IamgeUrlUp.Length == 0)
strUpImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.up.gif");
if (IamgeUrlDown.Length == 0)
strDownImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.down.gif");
if (IamgeUrlTop.Length == 0)
strTopImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.top.gif");
if (IamgeUrlBottom.Length == 0)
strBottomImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RD.WebControls.TwoListBox.bottom.gif");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
m_ImageRemoveLeft.ImageUrl = strLeftImageUrl;
m_ImageRemoveRight.ImageUrl = strRightImageUrl;
m_ImageRemoveAllLeft.ImageUrl = strLeftssImageUrl;
m_ImageRemoveAllRight.ImageUrl = strRightssImageUrl;
m_ImageRemoveUp.ImageUrl = strUpImageUrl;
m_ImageRemoveDown.ImageUrl = strDownImageUrl;
m_ImageRemoveTop.ImageUrl = strTopImageUrl;
m_ImageRemoveBottom.ImageUrl = strBottomImageUrl;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
m_ImageRemoveLeft.Attributes.Add( "alt", "左移");
m_ImageRemoveRight.Attributes.Add( "alt", "右移");
m_ImageRemoveAllLeft.Attributes.Add( "alt", "左移全部");
m_ImageRemoveAllRight.Attributes.Add( "alt", "右移全部");
m_ImageRemoveUp.Attributes.Add( "alt", "上移");
m_ImageRemoveDown.Attributes.Add( "alt", "下移");
m_ImageRemoveTop.Attributes.Add( "alt", "上移到頂");
m_ImageRemoveBottom.Attributes.Add("alt", "下移到底");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
m_ImageRemoveLeft.Attributes.Add( "onclick", "RemoveLeft()");
m_ImageRemoveRight.Attributes.Add( "onclick", "RemoveRight()");
m_ImageRemoveAllLeft.Attributes.Add( "onclick", "RemoveAllLeft()");
m_ImageRemoveAllRight.Attributes.Add( "onclick", "RemoveAllRight()");
m_ImageRemoveUp.Attributes.Add( "onclick", "RemoveUp()");
m_ImageRemoveDown.Attributes.Add( "onclick", "RemoveDown()");
m_ImageRemoveTop.Attributes.Add( "onclick", "RemoveTop()");
m_ImageRemoveBottom.Attributes.Add("onclick", "RemoveBottom()");
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
m_LeftListBox.SelectionMode = SelectionMode;
m_RightListBox.SelectionMode = SelectionMode;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
m_LeftListBox.Width = ListBoxWidth;
m_RightListBox.Width = ListBoxWidth;
m_LeftListBox.Height = ListBoxHeight;
m_RightListBox.Height = ListBoxHeight;
this.Width = Unit.Empty;
this.Height = Unit.Empty;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 用指定的資料源綁定左邊ListBox
/// </summary>
private void DataBindLeftListBox()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
m_LeftListBox.DataTextField = LeftListDataTextField;
m_LeftListBox.DataValueField = LeftListDataValueField;
m_LeftListBox.DataSource = LeftListDataSource;
m_LeftListBox.DataBind();
}
catch
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 用指定的資料源綁定右邊的ListBox
/// </summary>
private void DataBindRightListBox()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
m_RightListBox.DataTextField = RightListDataTextField;
m_RightListBox.DataValueField = RightListDataValueField;
m_RightListBox.DataSource = RightListDataSource;
m_RightListBox.DataBind();
}
catch
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//將隱藏欄位的值拆分轉換為數據Table
private DataTable ConcertHiddenTextBoxToTable(string strTextValue, string strTextField, string strValueField)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DataTable o_DataTable = new DataTable();
o_DataTable.Columns.Add(strTextField);
o_DataTable.Columns.Add(strValueField);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string[] ListBoxTextValue = strTextValue.Split('#');
for (int i = 0; i < ListBoxTextValue.Length && ListBoxTextValue.Length > 1; i += 2)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DataRow o_DataRow = o_DataTable.NewRow();
o_DataRow[0] = ListBoxTextValue[i];
o_DataRow[1] = ListBoxTextValue[i + 1];
o_DataTable.Rows.Add(o_DataRow);
}
return o_DataTable;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
#endregion
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
TwoListBox.js文件
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//左移動所選中的ListBox中的值
function RemoveLeft()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var LeftListBox=document.getElementById(ClentID+"_LeftListBox");
var RightListBox=document.getElementById(ClentID+"_RightListBox");
for(var i=0;i<RightListBox.options.length;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(RightListBox.options[i].selected==true)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var NewOption=document.createElement("option");
NewOption.value=RightListBox.options[i].value;
NewOption.text=RightListBox.options[i].text;
LeftListBox.options.add(NewOption);
RightListBox.options.remove(i);
i--;
}
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//右移動所選中的ListBox中的值
function RemoveRight()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var LeftListBox=document.getElementById(ClentID+"_LeftListBox");
var RightListBox=document.getElementById(ClentID+"_RightListBox");
for(var i=0;i<LeftListBox.options.length;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(LeftListBox.options[i].selected==true)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var NewOption=document.createElement("option");
NewOption.value=LeftListBox.options[i].value;
NewOption.text=LeftListBox.options[i].text;
RightListBox.options.add(NewOption);
LeftListBox.options.remove(i);
i--;
}
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//左移動ListBox中全部的值
function RemoveAllLeft()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var LeftListBox=document.getElementById(ClentID+"_LeftListBox");
var RightListBox=document.getElementById(ClentID+"_RightListBox");
for(var i=0;i<RightListBox.options.length;)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var NewOption=document.createElement("option");
NewOption.value=RightListBox.options[i].value;
NewOption.text=RightListBox.options[i].text;
LeftListBox.options.add(NewOption);
RightListBox.options.remove(i);
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//右移動ListBox中全部的值
function RemoveAllRight()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var LeftListBox=document.getElementById(ClentID+"_LeftListBox");
var RightListBox=document.getElementById(ClentID+"_RightListBox");
for(var i=0;i<LeftListBox.options.length;)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var NewOption=document.createElement("option");
NewOption.value=LeftListBox.options[i].value;
NewOption.text=LeftListBox.options[i].text;
RightListBox.options.add(NewOption);
LeftListBox.options.remove(i);
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//上移動右邊ListBox中選中的值
function RemoveUp()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var RightListBox=document.getElementById(ClentID+"_RightListBox");
for(var i=1;i<RightListBox.options.length;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(RightListBox.options[i].selected==true)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var strSelectText= RightListBox.options[i].text;
var strSelectValue= RightListBox.options[i].value;
RightListBox.options[i].text=RightListBox.options[i-1].text;
RightListBox.options[i].value=RightListBox.options[i-1].value;
RightListBox.options[i-1].text=strSelectText;
RightListBox.options[i-1].value=strSelectValue;
RightListBox.options[i].selected=false;
RightListBox.options[i-1].selected=true;
}
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//下移動右邊ListBox中選中的值
function RemoveDown()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var RightListBox=document.getElementById(ClentID+"_RightListBox");
for(var i=RightListBox.options.length-2;i>=0;i--)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(RightListBox.options[i].selected==true)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var strSelectText= RightListBox.options[i].text;
var strSelectValue= RightListBox.options[i].value;
RightListBox.options[i].text=RightListBox.options[i+1].text;
RightListBox.options[i].value=RightListBox.options[i+1].value;
RightListBox.options[i+1].text=strSelectText;
RightListBox.options[i+1].value=strSelectValue;
RightListBox.options[i].selected=false;
RightListBox.options[i+1].selected=true;
}
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//上移到頂端右邊ListBox中選中的值
function RemoveTop()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var RightListBox=document.getElementById(ClentID+"_RightListBox");
var first=RightListBox.firstChild;
for(var i=1;i<RightListBox.options.length;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(RightListBox.options[i].selected==true)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var NewOption = RightListBox.removeChild(RightListBox.options[i]);
RightListBox.insertBefore(NewOption,first);
RightListBox.options[0].selected=true;
}
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//上移到頂端右邊ListBox中選中的值
function RemoveBottom()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var curElement = event.srcElement;
var ClentID=curElement.parentNode.parentNode.parentNode.parentNode.id;
var RightListBox=document.getElementById(ClentID+"_RightListBox");
//循環計算選中的個數
var SelectLength=0;
for(var i=0;i<RightListBox.options.length;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(RightListBox.options[i].selected==true)
SelectLength++;
}
//順序移動到底端
for(var i=0;i<RightListBox.options.length;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(RightListBox.options[i].selected==true)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var NewOption = RightListBox.removeChild(RightListBox.options[i]);
i--;
NewOption.selected=false;
RightListBox.appendChild(NewOption);
}
}
//設置選擇
for(var i=RightListBox.options.length-1;i>=RightListBox.options.length-SelectLength;i--)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
RightListBox.options[i].selected=true;
}
GetListBoxValueToHiden(ClentID);
return false;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
//把當前2個ListBox中的值存入2個隱藏文本框中
function GetListBoxValueToHiden(ClentID)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
var LeftListBox=document.getElementById(ClentID+"_LeftListBox");
var RightListBox=document.getElementById(ClentID+"_RightListBox");
var LeftListBoxValue="";
var RigthListBoxValue="";
for(var i=0;i<LeftListBox.options.length;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
LeftListBoxValue+=LeftListBox.options[i].text+"#"+LeftListBox.options[i].value+"#";
}
for(var j=0;j<RightListBox.options.length;j++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
RigthListBoxValue+=RightListBox.options[j].text+"#"+RightListBox.options[j].value+"#";
}
if(LeftListBoxValue.length>0)
LeftListBoxValue=LeftListBoxValue.substring(0,LeftListBoxValue.length-1);
if(RigthListBoxValue.length>0)
RigthListBoxValue=RigthListBoxValue.substring(0,RigthListBoxValue.length-1);
document.getElementById(ClentID+"_LeftHiddenTextBox").value=LeftListBoxValue;
document.getElementById(ClentID+"_RightHiddenTextBox").value=RigthListBoxValue;
}