472,808 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

moving items from one list box to another

Kay
Hello,

I have two list boxes on my form, one initially displays with items and the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save button
on the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?

Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #1
5 11378
The problem is that you're using all client-side JavaScript to move the
item. Since the ViewState is not changed, and no event is fired, the server
side knows nothing about it. You have to have some way of informing the
server that a change has been made, and what made it. This can be
accomplished by wiring up a server-side event handler to do a PostBack and
move the data on the server side, or by putting some kind of hidden form
field into your client side that holds the data about the transfer, so that
when the PostBack occurs, your code can update the server-side lists.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Kay" <ka********@proteus.ie> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Hello,

I have two list boxes on my form, one initially displays with items and the other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save button on the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?
Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #2
Without knowing exactly how your code works, I only have a few simple
things to double check. First, are you writing any code in the Page_Load
method that would always overwrite the settings of your dropdown list?
Next, are you enabling the viewstate for each dropdown list?

Chris

--------------------
Reply-To: "Kay" <ka********@proteus.ie>
From: "Kay" <ka********@proteus.ie>
Subject: moving items from one list box to another
Date: Fri, 13 Feb 2004 15:08:15 -0000
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <OD**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 62.17.23.97
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13.
phx.gblXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:209871
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello,

I have two list boxes on my form, one initially displays with items and the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save buttonon the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?

Any help appreciated.
Thanks,
Kay.


Nov 18 '05 #3
What type of controls are you using? Are you using <select> elements or
<asp:ListBox> elements? Are you declaring these in your code behind? If your
Page.Load event handler or your declarative code is defining these elements
in their initial state, then you will need to detect IsPostBack and react
accordingly.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Kay" <ka********@proteus.ie> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Hello,

I have two list boxes on my form, one initially displays with items and
the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save
button
on the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed
event?

Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #4
Kay
Hi Chris,

On the page load event in the code behind file, I populate one of the list
boxes, the other listbox is not filled. I also populate the dropdownlist.
EnableViewState is set to true for both the listboxes and the dropdown list.

I have no problem with the dropdown list, this works fine, my problem is
trying to preserve the contents of the listboxes after the form is posted
back to the server due to the text changed event firing for the dropdown
list. When items are moved between the list boxes they redisplay as they
were originally displayed i.e one listbox displays blank regardless of what
had been moved into it.

Thanks,
Kay.

..""Coucou toutes et tous"" <cm****@nospamplease.com> wrote in message
news:$A**************@cpmsftngxa07.phx.gbl...
Without knowing exactly how your code works, I only have a few simple
things to double check. First, are you writing any code in the Page_Load
method that would always overwrite the settings of your dropdown list?
Next, are you enabling the viewstate for each dropdown list?

Chris

--------------------
Reply-To: "Kay" <ka********@proteus.ie>
From: "Kay" <ka********@proteus.ie>
Subject: moving items from one list box to another
Date: Fri, 13 Feb 2004 15:08:15 -0000
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <OD**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 62.17.23.97
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13. phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:209871X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello,

I have two list boxes on my form, one initially displays with items and theother displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save

button
on the form and I know when the user clicks this, I can retrieve the valuein the listbox by doing a Request.Form("listboxID") on the server, howeverthe dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?
Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #5
Kay
Hi Chris,

I am using ASP controls i.e. ListBox and dropdown list are both asp. All my
controls are declared in the code behind. I am using visual studio.net and
drag these controls on to my form at design time. My problem is when the
form posts back to the server as a result of the text changed event on the
dropdown list, when the screen is redisplayed any items that were moved
between the list boxes are lost i.e. the listboxes display as they
originally did when the page was first displayed.

Thanks,
Kay

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:OQ****************@TK2MSFTNGP09.phx.gbl...
What type of controls are you using? Are you using <select> elements or
<asp:ListBox> elements? Are you declaring these in your code behind? If your Page.Load event handler or your declarative code is defining these elements in their initial state, then you will need to detect IsPostBack and react
accordingly.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Kay" <ka********@proteus.ie> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Hello,

I have two list boxes on my form, one initially displays with items and
the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is posted back to the server and certain other processing happens, then when the form redisplays, the items that had been moved between the list boxes have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save
button
on the form and I know when the user clicks this, I can retrieve the value in the listbox by doing a Request.Form("listboxID") on the server, however the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I present the screen back to them after the dropdown list text changed
event?

Any help appreciated.
Thanks,
Kay.


Nov 18 '05 #6

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

Similar topics

12
by: Kevin Blount | last post by:
I'm playing with dragable <DIV>s, being inspired by google.com/ig, where you can move items on the page around and have items you move over change position if necessary. I have 3 div's setup,...
3
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays blank, and through javascript it is possible to move items from one box to another, this works fine, I followed an article titled...
2
by: florin | last post by:
I have to ListBox controls (or 2 html select controls with runat=server) on a web page and some buttons to move data from one listbox to another (using javascript). The problem is that when the...
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
3
by: Dany P. Wu | last post by:
Hi everyone, One of my Windows forms contain two listbox controls, with Add and Remove buttons between them. The idea is to allow users to select multiple items from one ListBox, click the...
6
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
1
by: OwlHoot | last post by:
I am using Thomas Fuchs's amazing drag-and-drop JavaScript library available at: http://wiki.script.aculo.us/scriptaculous/show/DragAndDrop to allow the user to select a subset of items listed...
1
by: MayhemMickells | last post by:
Alright soo, I'm working on this program for my programming class using VB 2005 and it's driving me insane. See the program is like this. The main form has a list box for selected products and...
4
by: HMS Surprise | last post by:
Just wondered if there was some python idiom for moving a few items from one list to another. I often need to delete 2 or 3 items from one list and put them in another. Delete doesn't seem to have...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.