using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Bonjour, hasan"; } protected void Button2_Click(object sender, EventArgs e) { foreach ( ListItem li in CheckBoxList1.Items) { li.Selected = true; } } protected void Button3_Click(object sender, EventArgs e) { ListBox1.Items.Add(TextBox1.Text); TextBox1.Text = ""; } protected void Button4_Click(object sender, EventArgs e) { ListBox1.Items.Remove(ListBox1.SelectedItem); } protected void Button5_Click(object sender, EventArgs e) { /* foreach (ListItem li in ListBox1.Items) { ListBox1.Items.Remove(li.Text); }*/ ListBox1.Items.Clear(); } protected void Button8_Click(object sender, EventArgs e) { ListBox2.Items.Add(ListBox1.SelectedItem); } protected void Button9_Click(object sender, EventArgs e) { foreach (ListItem li in ListBox1.Items) { ListBox2.Items.Add(li.Text); } ListBox1.Items.Clear(); /*foreach (ListItem li in ListBox2.Items) { ListBox1.Items.Remove(li.Text); }*/ } protected void Button7_Click(object sender, EventArgs e) { //via les indices /* foreach (int elt in ListBox2.GetSelectedIndices()) { ListBox1.Items.Add(ListBox2.Items[elt]) } */ // via l'etat selection foreach (ListItem li in ListBox2.Items) { ListBox1.Items.Add(li.Text); } ListBox2.Items.Clear(); } protected void Button6_Click(object sender, EventArgs e) { foreach (ListItem elt in ListBox2.Items) { if (elt.Selected) ListBox1.Items.Add(elt); } } }