473,788 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multi list box selector and post back question

I have two list boxes on my form... lstCanSend and lstRecipients.. . well
then there are two buttons add and remove between them (your basic select
and pick listing) which uses java script to move the items between list
boxes (the listbox controls are server side ones with runat=server set on
them, the buttons are basic html button i dont want to post back each time
someone clicks on add or remove... that wastes time and bandwidth) well the
add and remove buttons work, but at postback there is no data returned from
the lstRecipients listbox, because when the items were added through java
script it did not get posted back to data (i only want to post back when
thet user clicks on the OK button which sends this data to a processor) here
is my html code with the java script inside it... where should i do the post
back of the lstRecipient data and how do i do it when the user clicks on the
OK button? thanks
<%@ Register TagPrefix="cc1" Namespace="Secu reEmail" Assembly="Secur eEmail"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlTo p" Src="../Themes/ctrlTop.ascx"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlBo ttom"
Src="../Themes/ctrlBottom.ascx " %>
<%@ Register TagPrefix="uc1" TagName="ctrlLe ftSide"
Src="../Themes/ctrlLeftSide.as cx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlRi ghtSide"
Src="../Themes/ctrlRightSide.a scx" %>
<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Add ressBook.aspx.v b" Inherits="Secur eEmail.AddressB ook" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>The Reschini Secure E-Mail Network</title>
<meta name="ProgId" content="ShareP oint.WebPartPag e.Document">
<meta name="WebPartPa geExpansion" content="full">
<base target="_self">
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="Visual Basic .NET 7.1" name="CODE_LANG UAGE">
<meta content="VBScri pt" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<script language="javas cript">
function movePersonTo(fr om,to)
{
// Move this person from this list box to that listbox
for (var i=0; i < from.options.le ngth; i++)
{
var o = from.options[i];
if (o.selected)
{
to.options[to.options.leng th] = new Option(o.text,o .value,false,fa lse);
}
}

// delete from original list
for (var i = (from.options.l ength - 1); i >= 0; i--)
{
var o = from.options[i];
if (o.selected)
{
from.options[i] = null;
}
}

from.selectedIn dex = -1;
to.selectedInde x = -1;
}

</script>
</HEAD>
<body bottomMargin="0 " leftMargin="0" topMargin="0" rightMargin="0"
MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<table border="0" width="100%" id="table1" cellspacing="0"
cellpadding="0" height="100%">
<tr>
<td valign="top">
<uc1:ctrlTop id="CtrlTop1" runat="server"> </uc1:ctrlTop></td>
</tr>
<tr>
<td valign="top" height="100%">
<table border="0" width="100%" id="table2" height="100%"
cellspacing="0" cellpadding="0" >
<tr>
<td valign="top">
<uc1:ctrlLeftSi de id="CtrlLeftSid e1"
runat="server"> </uc1:ctrlLeftSid e></td>
<td valign="top" width="100%">
<TABLE id="table3" cellSpacing="0" cellPadding="0" width="100%"
bgColor="#a0c6e 5" border="0"
class="ToolBar ">
<TR>
<TD>
<P align="left">
<asp:button id="btmCloseAdd ress" runat="server" Text="OK"
CausesValidatio n="False" Font-Size="8pt"></asp:button></P>
</TD>
<TD>
<P align="right">< FONT face="Verdana" size="1"></FONT>&nbsp;</P>
</TD>
</TR>
</TABLE>
<table border="0" width="100%" id="table6" cellspacing="0"
cellpadding="0" >
<tr>
<td>
<cc1:ctrlPageHe aderBox id="ctrlPageHea derBox" runat="server"
Font-Size="8pt" Text="Address Book" AutoPostBack="T rue"></cc1:ctrlPageHea der
Box></td>
</tr>
</table>
<table border="0" id="table4" cellspacing="0" cellpadding="5" >
<tr>
<td><FONT face="Verdana" size="2"> Please choose the
recipients</FONT></td>
<td>&nbsp;</td>
<td><FONT face="Verdana" size="2"> Send to</FONT></td>
</tr>
<tr>
<td><asp:listbo x id="lstCanSend " runat="server" Width="208px"
Height="168px" SelectionMode=" Multiple"></asp:listbox>
</td>
<td>
<table border="0" width="100%" id="table5" height="100%"
cellspacing="0" cellpadding="0" >
<tr>
<td><INPUT type="button" value="Add"
onclick="movePe rsonTo(this.for m['lstCanSend'],this.form.lstR ecipients)">
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<P><INPUT type="button" value="Remove"
onclick="movePe rsonTo(this.for m['lstRecipients'],this.form.lstC anSend)"></P>
</td>
</tr>
</table>
<P>&nbsp;</P>
<P>&nbsp;</P>
</td>
<td><asp:listbo x id="lstRecipien ts" runat="server" Width="232px"
Height="166px" SelectionMode=" Multiple"></asp:listbox>
</td>
</tr>
</table>
<p>&nbsp;</p>
</td>
<td valign="top">
<uc1:ctrlRightS ide id="CtrlRightSi de1"
runat="server"> </uc1:ctrlRightSi de></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<uc1:ctrlBott om id="CtrlBottom1 " runat="server"> </uc1:ctrlBottom> </td>
</tr>
</table>
</form>
</body>
</HTML>
Nov 18 '05 #1
3 3104
Hi Brian,

As for the dropdownlist's items modification problem, I think this is
because the ASP.NET DropDownList server control or <select
runat="server"> ... (html server control) all store their items information
in the viewstate, so if we use the clientside script to modify their items
collection, it won't take effect when we post back the page to serverside.
Currently, I think you can consider the following two means;
1.Change the code to modify the list's item serverside (post back whenever
need to do modification)

2. still use client script, but we need to provide another place to store
the items info(or the modification info), for example, whenever we do
changes in the list, we store latest items collection in a <input
type=hidden> field. (use some split flag to separate the containg items).

In addition, here are some third-party list components which provide the
move list items between two list on both serverside or clientside, you may
also have a look:

#ListTransfer
http://www.asp.net/ControlGallery/Co...762&tabindex=2

#Ordered ListBox
http://www.asp.net/ControlGallery/Co...573&tabindex=2

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2
thanks

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:qh******** ******@cpmsftng xa10.phx.gbl...
Hi Brian,

As for the dropdownlist's items modification problem, I think this is
because the ASP.NET DropDownList server control or <select
runat="server"> ... (html server control) all store their items
information
in the viewstate, so if we use the clientside script to modify their items
collection, it won't take effect when we post back the page to serverside.
Currently, I think you can consider the following two means;
1.Change the code to modify the list's item serverside (post back whenever
need to do modification)

2. still use client script, but we need to provide another place to store
the items info(or the modification info), for example, whenever we do
changes in the list, we store latest items collection in a <input
type=hidden> field. (use some split flag to separate the containg items).

In addition, here are some third-party list components which provide the
move list items between two list on both serverside or clientside, you may
also have a look:

#ListTransfer
http://www.asp.net/ControlGallery/Co...762&tabindex=2

#Ordered ListBox
http://www.asp.net/ControlGallery/Co...573&tabindex=2

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
k r
In an attempt to postback my javascript-added items to my listbox, I
have declared the following hidden variable:

<input TYPE="hidden" NAME="hdnParts" >

In Javascript, when I add an item to my listbox I also add it to this
hidden variable.

Then, in my button event, I parse the hidden control, extract the added
items and add it to the server side listbox:

Request.Form["hdnParts"].Split(';');

The problem I have is that I have a third party control on my page that
causes a reload (postback). Upon reload my hidden variable is gone and
if the above button is pressed after this reload,
Request.Form("h dnParts"] gives me an empty string. How do I preserve the
hidden input value between postbacks. Another words, how do I achieve
the following in the old ASP world:

<input TYPE="hidden" NAME="hdnParts" value=<%request .form("hdnParts "%>>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

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

Similar topics

2
2110
by: | last post by:
I am hoping a mixed ASP- Javascript programmer could help me with this scenario: I have a list box populated with randomized records (NewID()) from a Broker (Salesperson) sql server table. Each time the user selects one of the broker items I need to display a Image of the broker in the table cell next to it. I have found a number of online js scripts that use the image selector route
115
7242
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." Yet if I use 'x-small' instead of 9pt, I get bigger type on IE6 and smaller type on Mozilla. My choices seem to be:
1
2728
by: Joe | last post by:
I have the following 3 tables: Clients, which has a numeric PK field called CLIENT_ID Languages, which has a numeric PK field called LANGUAGE_ID Client_Languages, which has a unique PK and foreign key fields CLIENT_ID and LANGUAGE_ID Clients and Languages each have a one-to-many relationship with
18
3352
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information from the dataset and how can I do that? Also, I set the property of the listbox to selectionmode...
6
11781
by: CindyH | last post by:
Hi Does anyone know how to create a multi column combo box from the same table? Thanks, Cindy
6
7197
by: _googlepost | last post by:
I have some CSS that goes something like this: table.TableStyle {font-family: "Helvetica", "Ariel"; background- color:white; border-collapse:collapse;} table.TableStyle COLGROUP { background- color:lavender;} The second line is a style that is applied to a particular named COLGROUP element in tables assigned the TableStyle class. Unfortunately, while this works in most modern browsers (including
0
1822
by: roggr11 | last post by:
Hi, I'm trying to define an XSD which allows me to have a multi-keyed XML- Node in the target-XML-files. Here's a shortened structure of such a file: <GenericElement xmlns="http://www.somens.com/elements" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.somens.com/elements GenericElement.xsd" >
17
3139
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note that I am using Allen Browne's multi-select list box for a report as a guide. I should also note that my access skills are not the best so I may need some explaining on certain things. First let me give some background on the database: I have a...
4
2032
by: aaronkmar | last post by:
Hello Bytes, I hope this post finds you well on this wonderful Friday! I've been kicking this code around for over a week now and cannot seem to find the correct syntax to handle all of the possible selections of my search form. Would someone please help me correct my IF statements in this code used for searching. Here's how it works.
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.