Thursday, March 22, 2012

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
henrikyou 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
>
>
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" <holle@.folter.org> wrote in message
news:OZtZBrEsEHA.3080@.TK2MSFTNGP15.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
>
Are you populating the listbox in the PageLoad method? If so you'll need to
test for
postback before populating listbox.
"Henrik Holle" <holle@.folter.org> wrote in message
news:OZtZBrEsEHA.3080@.TK2MSFTNGP15.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
|
|
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" <Clamps@.RobotMafia.Futurama.com> schrieb im Newsbeitrag
news:uYX89jFsEHA.2580@.TK2MSFTNGP15.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" <holle@.folter.org> wrote in message
> news:OZtZBrEsEHA.3080@.TK2MSFTNGP15.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
> |
> |
>

0 comments:

Post a Comment