473,748 Members | 7,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox item added with client scripts not submitting with ASP:Listbox

Help

I have a ASP:Listbox on a form. My page Adds items to this this via
Client-Side Script only.
Such as...

var vObj_TargetElem ent =
document.getEle mentById("_Page Template_innerH older_oASP_Lbx_ Invoice");
var vObj_SourceElem ent = document.getEle mentById("oHTML _Tbx_Invoice");
var vInt_OptionTota l = vObj_TargetElem ent.length++;
vObj_TargetElem ent.options[vInt_OptionTota l].value =
Trim(vObj_Sourc eElement.value) ;
vObj_TargetElem ent.options[vInt_OptionTota l].text =
Trim(vObj_Sourc eElement.value) ;
When the form is submitted, these new items are not submitted within the
LISTBOX.

Server-Side code such as ...
Response.Write( oASP_Lbx_Invoic e.Items.Count.T oString)

Returns 0 (zero)

Any ideas how to solve this ??

Thanks.

Simon

[Remove the NOSPAM if replying by email]
Nov 18 '05 #1
2 1444

"Simon Prince" <si**********@j oseph.NOSPAM.co .uk> wrote in message
news:cl******** ***********@new s.demon.co.uk.. .
Help

I have a ASP:Listbox on a form. My page Adds items to this this via
Client-Side Script only.
Such as...

var vObj_TargetElem ent =
document.getEle mentById("_Page Template_innerH older_oASP_Lbx_ Invoice");
var vObj_SourceElem ent = document.getEle mentById("oHTML _Tbx_Invoice");
var vInt_OptionTota l = vObj_TargetElem ent.length++;
vObj_TargetElem ent.options[vInt_OptionTota l].value =
Trim(vObj_Sourc eElement.value) ;
vObj_TargetElem ent.options[vInt_OptionTota l].text =
Trim(vObj_Sourc eElement.value) ;
When the form is submitted, these new items are not submitted within the
LISTBOX.

Server-Side code such as ...
Response.Write( oASP_Lbx_Invoic e.Items.Count.T oString)

Returns 0 (zero)

Any ideas how to solve this ??

Thanks.

Simon

[Remove the NOSPAM if replying by email]


It looks as though a listbox is read only as far as once it goes down to the
client as html. The server control does not look at what happens to the
list box once it leaves the server. When you go back to the server it uses
the server version to reload the box. I messed around with the code you
posted and that seems to be what is happening. It seems to be a one way
street. Is there any way to have the listbox do a postback to update it?
Nov 18 '05 #2
The way it is normally done is through a hidden field. Whenever your
client-side script runs to add the value to the list, add it to the hidden
field as well. On postback repopulate the listbox with the values from the
hidden field. You need to be careful because, if I remember correctly, the
listbox will retain whatever values were in it when it was originally sent to
the client. So either handle this case or always have the hidden field
represent values that were added during the current client session (prior to
postback).

I have seen a custom control somewhere that did just what you wanted but I
can't remember where. You could try Code Project or Code Guru.

Michael Taylor, MCP - 10/19/04

"Simon Prince" wrote:
Help

I have a ASP:Listbox on a form. My page Adds items to this this via
Client-Side Script only.
Such as...

var vObj_TargetElem ent =
document.getEle mentById("_Page Template_innerH older_oASP_Lbx_ Invoice");
var vObj_SourceElem ent = document.getEle mentById("oHTML _Tbx_Invoice");
var vInt_OptionTota l = vObj_TargetElem ent.length++;
vObj_TargetElem ent.options[vInt_OptionTota l].value =
Trim(vObj_Sourc eElement.value) ;
vObj_TargetElem ent.options[vInt_OptionTota l].text =
Trim(vObj_Sourc eElement.value) ;
When the form is submitted, these new items are not submitted within the
LISTBOX.

Server-Side code such as ...
Response.Write( oASP_Lbx_Invoic e.Items.Count.T oString)

Returns 0 (zero)

Any ideas how to solve this ??

Thanks.

Simon

[Remove the NOSPAM if replying by email]

Nov 18 '05 #3

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

Similar topics

10
2253
by: yop | last post by:
All When I try to get the text from my listbox I am get an error which is listed below. Any ideas? Thanks Object reference not set to an instance of an object.
1
8421
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What I want to do is to allow the user to click on the row that corresponds to the correct address, and have the code behind populate the form's Address1, Address2 etc. controls with the relevant data items. I put the code for this into the...
6
2878
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access the listbox object as an object to set the listitem's selected property before it gets rendered).. ...
1
2266
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the button_click function because the only way to find the listbox is: (listbox)e.item.findcontrol What s the solution to this problem?
6
6183
by: Steve | last post by:
Hi, I open up a webform (vb.net) and populate a listbox control on the Page load event. If I click on (select) and item from the listbox I want to write the value of the selected item to a label control. Nothing happens. But when I click a button (which contains same code to write to label) I get the value of the selected item in the Label.
4
5104
by: Bob P. | last post by:
Hello, I have a page with: * two side-by-side asp:listboxes and two arrow asp:buttons allowing users to add/remove email addresses between them -- very much like Outlook, where you have the address book on the left, and you build the message recipients on the right. * an asp:button that, when clicked, fires off some code to create and send the mail message
10
3303
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
2
3617
by: Mark Rae | last post by:
Hi, Looking for some advice again... Imagine two ListBox controls denoting something like students and team membership e.g. many students can be members of many teams (e.g. the hockey team, the football team, the athletics team etc). Team membership is managed on a standard web page with two ListBox controls - the one on the left shows which team(s) the student is not a
2
2915
by: teo | last post by:
I have a Listbox, if I set EnableViewStarte = False the AutopostaBack fired by SelectedIndexChanged doesn't work. The 'SelectedIndexChanged' event should call
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
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
9367
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
9319
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
8241
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
6795
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
6073
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
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.