asp.net:listbox accessing values

Discussion in 'ASP .Net' started by undercups, May 14, 2005.

  1. undercups

    undercups Guest

    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
    undercups, May 14, 2005
    #1
    1. Advertising

  2. undercups

    undercups Guest

    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
    undercups, May 18, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blenderdude
    Replies:
    0
    Views:
    748
    blenderdude
    Aug 3, 2003
  2. Brian Henry
    Replies:
    5
    Views:
    10,015
    Steven Cheng[MSFT]
    Aug 3, 2004
  3. Simon Prince
    Replies:
    2
    Views:
    3,307
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  4. =?Utf-8?B?QW5kZXJzIEphbnNzb24=?=

    Problems with accessing ASP.NET Session values in ASP

    =?Utf-8?B?QW5kZXJzIEphbnNzb24=?=, Dec 10, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,784
    =?Utf-8?B?QW5kZXJzIEphbnNzb24=?=
    Dec 14, 2004
  5. Dessip
    Replies:
    1
    Views:
    576
    Dessip
    Jul 5, 2006
Loading...

Share This Page