473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ListBox clientside changes not reflecting on serverside code

Hi,

I have some code that looks like this:

-- CODE ----------------------------
Public Class NodeEditor
Inherits System.Web.UI.Page

Protected WithEvents ChildList As System.Web.UI.WebControls.ListBox

Private Sub Page_Load(...) Handles MyBase.Load
'nothing relevant to the ChildList
End Sub

Private Sub SubmitButton_Click(...) Handles SubmitButton.Click
Dim count As Integer = ChildList.Items.Count
End Sub
-- CODE ----------------------------

Why is the value of 'count' zero no matter how many elements are added
to the ListBox in clientside jscript code?
In other words, why arent clientside changes being reflected after the
form is posted?

Thanks in advance,

Luis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
2 2251
Luis:
When you add ListItems to a dropdownlist on the SERVER, that information is
persisted in the viewstate. When you select an item, and postback, all the
listitems are re-created from the viewstate, and the selected one is
determined from the value in the Request.Form. Only selected values are
present in REquest.Form which is why the values are initially stored in the
viewstate.

When you don't create any values on the server, obviously there's no values
for the viewstate to persist. when you create them on the CLIENT and select
a value, the listitems are re-created from the viewstate - in this case
there are no listitems in the viewstate. The only information the server
has on postback at this point is the selected value in the shape of
Request.Form...but this isn't even close to enough information to rebuild
it.

Short answer to your question is that it just doesn't work that way.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Luis Ferrao" <lf*@undisclosed.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I have some code that looks like this:

-- CODE ----------------------------
Public Class NodeEditor
Inherits System.Web.UI.Page

Protected WithEvents ChildList As System.Web.UI.WebControls.ListBox

Private Sub Page_Load(...) Handles MyBase.Load
'nothing relevant to the ChildList
End Sub

Private Sub SubmitButton_Click(...) Handles SubmitButton.Click
Dim count As Integer = ChildList.Items.Count
End Sub
-- CODE ----------------------------

Why is the value of 'count' zero no matter how many elements are added
to the ListBox in clientside jscript code?
In other words, why arent clientside changes being reflected after the
form is posted?

Thanks in advance,

Luis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #2
Thanks Karl, this is crystal clear.

Since i have no way of knowing what or how much information is going to
be added, i'll use a text box with coma separated values. The textbox
should be present and persisted in the viewstate at all times.

Once again, thank you for your help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3

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

Similar topics

2
by: Alpha | last post by:
I have a window application. On one of the form, there is a listbox and a few combox. The lstSchItem has a dataview as a datasource. The comboxes are bind to its selected value but through the...
4
by: Henrik Holle | last post by:
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...
3
by: RFS666 | last post by:
Hello together, I tried to find out about populating an asp.net server control (a dropdownlist) from the clientside jscript, but I didn't find a solution up to now. I cannot use a html...
1
by: RFS666 | last post by:
Hello together, I wanted to ask if somebody can help me with accessing a listbox (a serverside webform from the designer-toolbox) from clientside JScript. I need to add and remove values and...
0
by: Clark Stevens | last post by:
I have an ArrayList (CAL) bound to a listbox (Listbox1). I want to delete an item in the ArrayList and reflect the changes back to the listbox. I have no problem deleting ArrayList items, but how...
4
by: Hans | last post by:
Hi, I have created an extension that only runs on the serverside and not on both the client and the server side. I have to in the BeforeDeSerialize fix my dateTime so the deserialisation...
2
by: Anup | last post by:
Hi Group, In my application there is a very common functionality, where two list box and present and items are moved between them on button clicks when selected, This I am doing client side,...
1
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...
7
by: mc | last post by:
I've not been able to get a Check box to client side validated on postback. with my changes I can get it to work on the serverside ok but not on the client. I have created a new control as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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...

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.