asp.net:listbox accessing values

U

undercups

his is a hybrid problem i.e. the answer lies either in javascript or
vb.net so forgive me if this is the wrong group.

I have this javascript:

function moveItems(fromItem, toItem)
// Moves selected items from one ListBox to another.
{
var NoofItems = fromItem.options.length
for (i=0; i < NoofItems; i++)
{
if (fromItem.children.selected )
{
var anode = fromItem.children.cloneNode (true)
toItem.appendChild(anode)
fromItem.removeChild(fromItem. children)
NoofItems = fromItem.children.length
i--
}
}
}

which when called appears to move an item from 1 listbox to another.
However in vb.net when I run this code
If TeamDivisions.Items.Count > 0 Then
For intCount = 0 To TeamDivisions.Items.Count -
1
.WriteStartElement("TeamDivisi ons")
TeamDivisions.SelectedIndex = intCount
.WriteAttributeString("Divisio nId",
TeamDivisions.SelectedItem.Val ue)
.WriteEndElement()
Next
End If

the TeamDivisions.Items.Count returns 0 even when I know there are rows
in the control.

Any ideas why this control cannot be accessed in vb.net? In vb.net's
immediate window I can access the listbox from which the items are
removed to the above control using Items.Count, SelectedIndex,
SelectedItem.Value without a problem but the receiving list listbox
i.e. TeamDivisiones doesn't work at all.

Does the problem lie with my javascript?

Thanks for your help

Duncan
 
U

undercups

Sorted it
I found I had to have a hidden input field and when the page is
submitted append the values in the listbox to the hidden field. In
my case this looked like "1,2,3". I then used vb.net to split the
values.
The reason for this is apparently the text and values in a listbox are
not posted back to the server.

Hope this helps

Duncan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top