473,320 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to move items from one listbox to another on a client side?

Hi,

I have two listboxes on a page and need to move items between them - using
buttons (e.g. "<<" ">>"). Can this be done on a client side in asp.net?
I'd like to avoid hitting the server on every add/remove.

Thanks,
Bogdan
Jun 27 '08 #1
4 4614
You can move them using JavaScript, if you wish. You will still have to take
a server trip to commit back to the database, however. A simple example is
here (will not vouch for code, however):

http://www.codeproject.com/KB/aspnet...combo_box.aspx

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"bogdan" <bo****@nospam.comwrote in message
news:Oh**************@TK2MSFTNGP02.phx.gbl...
Hi,

I have two listboxes on a page and need to move items between them - using
buttons (e.g. "<<" ">>"). Can this be done on a client side in asp.net?
I'd like to avoid hitting the server on every add/remove.

Thanks,
Bogdan


Jun 27 '08 #2
"bogdan" <bo****@nospam.comwrote in message
news:Oh**************@TK2MSFTNGP02.phx.gbl...
I have two listboxes on a page and need to move items between them - using
buttons (e.g. "<<" ">>"). Can this be done on a client side in asp.net?
I'd like to avoid hitting the server on every add/remove.
http://www.google.co.uk/search?sourc...avaScript+move
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #3
Thanks for the reply. Since I'm rather new to asp.net I think I
miscalculated what I could do on the client side. I have the code working
moving items between listboxes but have no clue how to pass items of one of
the listboxes back to the server. I could put a 'Save' button that would
post back to the server but I don't know how to pass the new set of items in
the listbox. The old ones are in the viewstate. Is there a way to do that?
I might try to select all items on the client side before posting back but
I'm afraid that this might not work because of discrepancies between old
items and selected ones (e.g. selected items were not present in the list
when it was sent to the client).

Any help would be appreciated.

Thanks,
Bogdan
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:e0**************@TK2MSFTNGP03.phx.gbl...
You can move them using JavaScript, if you wish. You will still have to
take a server trip to commit back to the database, however. A simple
example is here (will not vouch for code, however):

http://www.codeproject.com/KB/aspnet...combo_box.aspx

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box! |
*************************************************
"bogdan" <bo****@nospam.comwrote in message
news:Oh**************@TK2MSFTNGP02.phx.gbl...
>Hi,

I have two listboxes on a page and need to move items between them -
using buttons (e.g. "<<" ">>"). Can this be done on a client side in
asp.net? I'd like to avoid hitting the server on every add/remove.

Thanks,
Bogdan



Jun 27 '08 #4
"bogdan" <bo****@nospam.comwrote in message
news:em**************@TK2MSFTNGP03.phx.gbl...
Thanks for the reply. Since I'm rather new to asp.net I think I
miscalculated what I could do on the client side. I have the code working
moving items between listboxes but have no clue how to pass items of one
of the listboxes back to the server. I could put a 'Save' button that
would post back to the server but I don't know how to pass the new set of
items in the listbox. The old ones are in the viewstate. Is there a way
to do that? I might try to select all items on the client side before
posting back but I'm afraid that this might not work because of
discrepancies between old items and selected ones (e.g. selected items
were not present in the list when it was sent to the client).
Client-side changes to the element collection of listboxes are not persisted
across a postback.

Therefore, the "usual" workaround for this is to populate a hidden text box
with as much information as the server-side code needs for its purposes.

E.g. if the "first" listbox contains the following elements:

First
Second
Third
Fourth
Fifth

and it's possible client-side to move any or all of these elements into the
"second" listbox, just before the postback happens (e.g. in the
OnClientClick of a button control) inspect the contents of the "second"
listbox. Let's say that the second listbox now contains the first, third and
fifth elements from the first listbox. Therefore, place the following value
in a hidden text box: "1¬3¬5". This will be posted back to the server along
with the rest of the web form where it will be a simple matter to parse out
the value and identify which of the elements had been moved from the first
listbox to the second.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim M | last post by:
I am having trouble changing any properties of the web form listbox from client side javascript. As an example, all of the lines below seem to cause an error... temp =...
1
by: kent | last post by:
Hi All, On my form, I have 2 listboxes that get populated with the correct items. I have 4 buttons between the 2 boxes. The first 2 buttons are used to move the selected item back and forth...
6
by: Valerian John | last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the ListBox using client-side code. However, when the page is posted back the items are missing/not available. (It is like the...
4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
3
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save...
1
by: Partha Sarathy.G | last post by:
I have code for moving the items from one list box to another listbox at client side For more details mail to gps.mca@gmail.com
1
by: BillAtWork | last post by:
Hi, I have a listbox (in a user control) which has items add/removed via javascript (i.e. an "add item" link which uses a popup selection screen to add items and a "remove item" link which deletes...
1
by: anjupt | last post by:
Hi, I have 2 listboxes with data fetched from database so for both the listboxes datasource is set .i tried to move data from one listbox to another listbox but Error"An unhandled exception of...
15
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.