473,386 Members | 1,908 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,386 software developers and data experts.

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="SecureEmail" Assembly="SecureEmail"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlTop" Src="../Themes/ctrlTop.ascx"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlBottom"
Src="../Themes/ctrlBottom.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlLeftSide"
Src="../Themes/ctrlLeftSide.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlRightSide"
Src="../Themes/ctrlRightSide.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="AddressBook.aspx.vb" Inherits="SecureEmail.AddressBook" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>The Reschini Secure E-Mail Network</title>
<meta name="ProgId" content="SharePoint.WebPartPage.Document">
<meta name="WebPartPageExpansion" content="full">
<base target="_self">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="VBScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="javascript">
function movePersonTo(from,to)
{
// Move this person from this list box to that listbox
for (var i=0; i < from.options.length; i++)
{
var o = from.options[i];
if (o.selected)
{
to.options[to.options.length] = new Option(o.text,o.value,false,false);
}
}

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

from.selectedIndex = -1;
to.selectedIndex = -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:ctrlLeftSide id="CtrlLeftSide1"
runat="server"></uc1:ctrlLeftSide></td>
<td valign="top" width="100%">
<TABLE id="table3" cellSpacing="0" cellPadding="0" width="100%"
bgColor="#a0c6e5" border="0"
class="ToolBar ">
<TR>
<TD>
<P align="left">
<asp:button id="btmCloseAddress" runat="server" Text="OK"
CausesValidation="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:ctrlPageHeaderBox id="ctrlPageHeaderBox" runat="server"
Font-Size="8pt" Text="Address Book" AutoPostBack="True"></cc1:ctrlPageHeader
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:listbox 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="movePersonTo(this.form['lstCanSend'],this.form.lstRecipients)">
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<P><INPUT type="button" value="Remove"
onclick="movePersonTo(this.form['lstRecipients'],this.form.lstCanSend)"></P>
</td>
</tr>
</table>
<P>&nbsp;</P>
<P>&nbsp;</P>
</td>
<td><asp:listbox id="lstRecipients" runat="server" Width="232px"
Height="166px" SelectionMode="Multiple"></asp:listbox>
</td>
</tr>
</table>
<p>&nbsp;</p>
</td>
<td valign="top">
<uc1:ctrlRightSide id="CtrlRightSide1"
runat="server"></uc1:ctrlRightSide></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<uc1:ctrlBottom id="CtrlBottom1" runat="server"></uc1:ctrlBottom></td>
</tr>
</table>
</form>
</body>
</HTML>
Nov 18 '05 #1
3 3074
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.microsoft.com> wrote in message
news:qh**************@cpmsftngxa10.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("hdnParts"] 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
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. ...
115
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 ..." ...
1
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...
18
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...
6
by: CindyH | last post by:
Hi Does anyone know how to create a multi column combo box from the same table? Thanks, Cindy
6
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-...
0
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...
17
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.