473,835 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListBox and Javascript

Hi,

i have a serverside listbox but i modify the value with javascript on the
clientside. On postback my changed/added values are all lost? what am i
doing wrong? Is it not possible to change the listbox content on the
clientside?

regards

henrik
Nov 18 '05 #1
4 5380
you can add the values to a list box using javascript.
alternatively you can keep a hidden textbox and add the value of the item
addded to the listbox as a comma seperated value and get these values at the
server side.
HTH
srini

"Henrik Holle" wrote:
Hi,

i have a serverside listbox but i modify the value with javascript on the
clientside. On postback my changed/added values are all lost? what am i
doing wrong? Is it not possible to change the listbox content on the
clientside?

regards

henrik

Nov 18 '05 #2
Not if the listbox is being re-created from viewstate (which is probably
what's happening). The only solution I know of is when the submit button is
clicked, to highlight all items in the listbox and use good'ol Request.Form
to access the values..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Henrik Holle" <ho***@folter.o rg> wrote in message
news:OZ******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

i have a serverside listbox but i modify the value with javascript on the
clientside. On postback my changed/added values are all lost? what am i
doing wrong? Is it not possible to change the listbox content on the
clientside?

regards

henrik

Nov 18 '05 #3
Are you populating the listbox in the PageLoad method? If so you'll need to test for
postback before populating listbox.

"Henrik Holle" <ho***@folter.o rg> wrote in message
news:OZ******** ******@TK2MSFTN GP15.phx.gbl...
| Hi,
|
| i have a serverside listbox but i modify the value with javascript on the
| clientside. On postback my changed/added values are all lost? what am i
| doing wrong? Is it not possible to change the listbox content on the
| clientside?
|
| regards
|
| henrik
|
|

Nov 18 '05 #4
ok, i build a workaround with a hiddenfield and onsubmit/postback i am
parsing the values and add the listitems by hand.

thx for your help
"Clamps" <Cl****@RobotMa fia.Futurama.co m> schrieb im Newsbeitrag
news:uY******** ******@TK2MSFTN GP15.phx.gbl...
Are you populating the listbox in the PageLoad method? If so you'll need
to test for
postback before populating listbox.

"Henrik Holle" <ho***@folter.o rg> wrote in message
news:OZ******** ******@TK2MSFTN GP15.phx.gbl...
| Hi,
|
| i have a serverside listbox but i modify the value with javascript on
the
| clientside. On postback my changed/added values are all lost? what am i
| doing wrong? Is it not possible to change the listbox content on the
| clientside?
|
| regards
|
| henrik
|
|

Nov 18 '05 #5

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

Similar topics

2
2917
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However, currently the code is such that with each selection there is a postback. We want to avoid it using filter and javascript. I am not using ADO.NET but adodbc and no datagrids or datasets (please don't tell me that i should as my boss clearly doesn't want...
1
9871
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't work. Thanks ahead.
4
5109
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
0
1590
by: deepak | last post by:
Hi all, i m transefering values from one listbox to another listbox using javascript(both are html controls), the first listbox is populating with database at page_load time and the second listbox is empty initially .the two buttons which i have taken are both(btnAd,btnRemove) have values Add,Remove and both are input type with run as server control property set to true,.my script is given below , however when i click on add button the ...
6
5231
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I have also tried changing the second ListBox to an HtmlSelect control) using bog standard JavaScript code like so where "used" is the name of my <select> control: used.options = new Option(name, typeId); This all works fine and I can move across...
4
1861
by: collie | last post by:
HI, I need to populate 2 listboxes from a db. When the page loads then the first listbox needs to be populated and based on selection from that listbox the second listbox needs to be populated accordingly with the matching items. However, my boss doesn't want the page to do a postback once an item from the first listbox is selected. also, he doesn't want to use ado.net but classic ado. He wants to use jscript. I am writing my code in...
4
2804
by: Jeff | last post by:
....still new at this. ...hopefully a simple question Is there some practical way of altering the function of a keypress in Visual Web.net 2005 using VB without causing a postback on each keypress? For example: A have a listbox with a number of selections. The up and down keyboard keys change the indicated listbox selection and by default the <tabkey takes the focus away from the listbox and onto a button that will submit the selection. I'm...
7
5635
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client browser the list box scroll position is at the top.
7
3238
by: mikeh3275 | last post by:
I'm creating a .net program that uploads images to the FTP server. A blank listbox is populated dynamically on the client side from the value of the html input file widget. There is also a requiredfieldvalidator on the listbox to make sure there is an item in the listbox. When I click the button to submit, however, the listbox clears itself and a validation error shows. Below is the relevant code in C# plus the Javascript code. Thanks in...
15
2375
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make things look better visually for that, I created a listbox under the text box. She enters the number in the text box, clicks another button I added and the number is stored in the list box. Then my plan was to grab all those numbers from the list box...
0
10808
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
10520
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
10560
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
10233
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9344
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
7766
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
6963
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
5636
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...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.