Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

ListBox populated with Javascript shows no members upon Callback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Kotuby - 12 Mar 2008 15:49 GMT
Hi all,

I was wondering if what I am seeing is to be expected or maybe I'm setting
things up wrong with the Update Panels. I am programming in VS 2008 with VB.

I have a page with multiple update panels. At the bottom of the page I have
an update panel with UpdateMode="Always" where I store hidden fields. I use
them for communication with the server and maintaining state upon Callbacks.
The fields appear to be always Read/Write accessible at the server during
the page callback.

One of the other update panels is set to UpdateMode="Conditional"
ChildrenAsTriggers="false" and I have defined some trigger buttons
(AsyncPostBackTrigger) that are clicked from within JavasScript functions.
There is an asp listbox (Id = "lstSelected") in that panel which I populate
clientside using the JavaScript DOM, depending on what the user selects from
a Grid .

Upon callback with the Trigger defined for the update panel, I discover that
in Page_Load Me.lstSelected.Items.Count = 0. There are no Items found in the
lisbox even though they were clearly there in the Browser document having
been placed there with JavaScript. Is this to be expected that listboxes
populated in this manner show as empty at the server during callback?

I have resorted to populating some hidden fields with delimited strings
representing the contents of the listbox. These are populated at the same
time as the listbox entries are created via JavaScript...but as I said, for
some reason they persist.

Can anyone tell me why I might be seeing this type of behavior?

Thanks for any replies.
bruce barker - 12 Mar 2008 16:33 GMT
the browser only posts back the selectedValue of a listbox (select), so any
changes done to list are not refected on server. if viewstate is enabled, the
server saves the orginal list in viewstate, and restores the list from this
on postback. as viewstate is encrypted, client code can not modify it.

in you case you should turn viewstate off, store the list data in a hidden
field (updated on the client side, say with json), then in oninit load the
list from the hidden field.

-- bruce (sqlwork.com)

> Hi all,
>
[quoted text clipped - 28 lines]
>
> Thanks for any replies.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.