• Home
  • About
  • Streaming

xneuron

eXtreme Neuron

Feeds:
Posts
Comments

Move Items From One ListBox To Another

October 25, 2007 by bnma

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Untitled Page</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<asp:ListBox ID=”LBSource” SelectionMode=”Multiple” runat=”server”>

  <asp:ListItem Text=”Item1″ Value=”vItem1″></asp:ListItem>

  <asp:ListItem Text=”Item2″ Value=”vItem2″></asp:ListItem>

  <asp:ListItem Text=”Item3″ Value=”vItem3″></asp:ListItem>

  <asp:ListItem Text=”Item4″ Value=”vItem4″></asp:ListItem>

  <asp:ListItem Text=”Item5″ Value=”vItem5″></asp:ListItem>

</asp:ListBox>

<input type=”button” value=”Add” onclick=”moveItems(‘<%= LBSource.ClientID %>‘, ‘<%= LBDestination.ClientID %>‘)” />

<input type=”button” value=”Remove” onclick=”moveItems(‘<%= LBDestination.ClientID %>‘, ‘<%= LBSource.ClientID %>‘)” />

<asp:ListBox ID=”LBDestination” SelectionMode=”Multiple” runat=”server”></asp:ListBox>

</div>

</form>

<script language=”javascript” type=”text/javascript”>

function moveItems(srcID, dstID)

{

  src = document.getElementById(srcID);

  dst = document.getElementById(dstID); var found = true;

  while (found)

  {

    found = false;

    for (var i = 0; i < src.length; i++)

    {

      if (src[i].selected)

      {

        dst.appendChild(src[i].cloneNode(true));

        src.removeChild(src[i]);

        found = true;

        break;

      }

    }

  }

}

</script>

</body>

</html>

Posted in .Net, ASP.Net, C#, HTML, JavaScript, Uncategorized | No Comments Yet

  • Pages

    • About
    • Streaming
  • c

  • Top Posts

    • Copy Directory And Its Content To Another Directory In C#
    • String.Format() In JavaScript As In C#
    • Convert an ArrayList of strings to a string[] array
    • Deserialize XML string
    • X509 Certificate Installation
    • Move Items From One ListBox To Another
    • Page Postbacks And Client Callbacks
    • Launch Cassini Using Command Line
    • File MIME Type Using C#
    • Filtering Non-Numeric Characters In A Textbox Using Javascript
  • Recent Posts

    • Url Validation In Javascript
    • Script To Search Text In Database
    • Launch Cassini Using Command Line
    • Max File Size Upload In ASP.Net
    • File MIME Type Using C#
  • Archives

    • June 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • October 2008
    • August 2008
    • May 2008
    • April 2008
    • February 2008
    • December 2007
    • October 2007
    • September 2007
    • April 2007
    • January 2007
    • November 2006
    • October 2006
    • September 2006
  • Blog Stats

    • 69,064 hits
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.com
  • Watch videos at Vodpod and other videos from this collection.

Blog at WordPress.com.

Theme: Mistylook by Sadish.