473,657 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding items to listbox through java script then accessing through asp.net

I am trying to add some items to a list box in java script, they add just
fine, the values and text are how they should be. The problem though is when
I try to access these added items from asp.net they do not show up, If i
place a button on the same form that is a server control, click it, i'd
expect the lists to be posted back too... but they dont appear to be because
the collections for the list boxes were empty, how do you get a list box to
post back data that was added through a java script command on the client
side? thanks
Nov 18 '05 #1
5 2453
It's a known question. Server-side doesn't know about this sort of
client-side changes.

Eliyahu

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to add some items to a list box in java script, they add just
fine, the values and text are how they should be. The problem though is when I try to access these added items from asp.net they do not show up, If i
place a button on the same form that is a server control, click it, i'd
expect the lists to be posted back too... but they dont appear to be because the collections for the list boxes were empty, how do you get a list box to post back data that was added through a java script command on the client
side? thanks

Nov 18 '05 #2
yes, but how do you deal with posting them back to the server after the
client is done with the data? i have seen commercial asp.net controls
written that do changes client side like this then post back to the
server... so i know it is possible to do this... but how is my question
"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
It's a known question. Server-side doesn't know about this sort of
client-side changes.

Eliyahu

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to add some items to a list box in java script, they add just fine, the values and text are how they should be. The problem though is

when
I try to access these added items from asp.net they do not show up, If i
place a button on the same form that is a server control, click it, i'd
expect the lists to be posted back too... but they dont appear to be

because
the collections for the list boxes were empty, how do you get a list box

to
post back data that was added through a java script command on the client side? thanks


Nov 18 '05 #3
There are standard ways of passing data from client to server. Most popular
is in <input type=hidden ...>. You can make a string out of the items and
parse it on the server. I won't be surprised if someone will offer a better
idea though.

Eliyahu

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:ev******** ******@TK2MSFTN GP10.phx.gbl...
yes, but how do you deal with posting them back to the server after the
client is done with the data? i have seen commercial asp.net controls
written that do changes client side like this then post back to the
server... so i know it is possible to do this... but how is my question
"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
It's a known question. Server-side doesn't know about this sort of
client-side changes.

Eliyahu

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to add some items to a list box in java script, they add just fine, the values and text are how they should be. The problem though is
when
I try to access these added items from asp.net they do not show up, If
i place a button on the same form that is a server control, click it, i'd expect the lists to be posted back too... but they dont appear to be

because
the collections for the list boxes were empty, how do you get a list
box to
post back data that was added through a java script command on the

client side? thanks



Nov 18 '05 #4
hey, its a start :) an idea is better then no idea

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...
There are standard ways of passing data from client to server. Most popular is in <input type=hidden ...>. You can make a string out of the items and
parse it on the server. I won't be surprised if someone will offer a better idea though.

Eliyahu

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:ev******** ******@TK2MSFTN GP10.phx.gbl...
yes, but how do you deal with posting them back to the server after the
client is done with the data? i have seen commercial asp.net controls
written that do changes client side like this then post back to the
server... so i know it is possible to do this... but how is my question
"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
It's a known question. Server-side doesn't know about this sort of
client-side changes.

Eliyahu

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
> I am trying to add some items to a list box in java script, they add just
> fine, the values and text are how they should be. The problem though is when
> I try to access these added items from asp.net they do not show up,
If i > place a button on the same form that is a server control, click it, i'd > expect the lists to be posted back too... but they dont appear to be
because
> the collections for the list boxes were empty, how do you get a list box to
> post back data that was added through a java script command on the

client
> side? thanks
>
>



Nov 18 '05 #5
Hi Brian,

I think Eliyahu's suggestion that use the <input hidden > field is quite
reasonble for your situation and I've also posted my reply and provide some
suggestions in another post titled "Multi list box selector and post back
question". I'd appreciate if you also have a look there .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 #6

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

Similar topics

1
2908
by: Vengeance | last post by:
On the parent_form.aspx I have these controls <asp:listbox id="Operators" runat="server" Width="163px" SelectionMode="Multiple" Rows="2"></asp:listbox> <INPUT class="loButton" onclick="java script:getOptionPicker('?mid=TS5 &callingcontrol=Operators');" type="button" value="+"> <asp:button id="save" runat="server" CssClass="loButton" Text="Save"> </asp:button> I also use a global.js file which adds the following functions
6
8060
by: Scott | last post by:
The code below appears to work on the following: MAC - Safari PC - IE PC - Opera But the addition of items to the dropdown (select2) does not function in: MAC – IE
1
1585
by: Brian Henry | last post by:
I haven't worked with java script much, I know how to do this server side by constant post backs to the server on a webform, but it seems like i should be able to do this client side also... What happens is a modal dialog recieves a listing of users in a semi-colon delimited list so its like this user_1;user_2;user3;user_4; what I need to do is split this up in javascript and place each user into a
3
2718
by: Ryan Taylor | last post by:
Hello. I have an application where I need the user to be able to add items to a listbox. I've implemented this via javascript. The listbox is an <asp:ListBox>. However, when the user submits the form those items do not get posted. My listbox.Items.Count always returns 0. I want the user to be able to add items without having to resort to a postback, hence the javascript. But I need to be able to access those items in the code behind...
6
3655
by: Papa.Coen | last post by:
I've just spend a lot of time solving the following problem: I used dotNet 2.0 / Visualstudio 2005 / C# / aspx, enable viewstate is set on all controls. I have 2 listboxes; the left contains items that can be (dynamically) added to the right box. Adding the first item went fine, it shows up in the right box. Adding the second item resulted in losing _every_ control following the right box. 'View source' reveiled that the rendering of the...
14
18713
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe is that as more and more are added, population of the list box takes longer and longer. ie the first 10th of the item set are added much much quicker than the last 10th. THis occurs with about 40,000 listbox items. My worry is the listbox may...
1
12778
by: bill | last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML <select runat=server>) using clientside javascript, and retrieve the items when the page is posted back. I use this code to add the option to the listbox. It works for <select> or <asp:listbox> controls. var opt = document.CreateElement("OPTION"); opt.text = "test"; opt.value="test";
2
2968
by: =?Utf-8?B?TWFobW91ZCBTaGFiYW4=?= | last post by:
i have a problem in adding new listbox items i don't need to allow adding multible items with the same textvalue ex: if current items are: green red
1
3663
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
8402
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
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7341
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
6172
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
5633
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
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
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
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
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.