ASP.NET Listbox Client Side changes not reflected on page

Discussion in 'ASP .Net' started by chandru, Jul 20, 2007.

  1. chandru

    chandru Guest

    Hi,
    I am adding some values to the ASP.NET ListControl on the client side
    javascript
    and this is not reflecting on the server side.
    I thought the input and select fields should reflect the changes on
    the server side.
    I know that the post backs doesn't post all of the HTML only the
    changes etc,etc.

    I am adding so many values to the list on the client side so I can't
    have an hidden input field.
    That will make things complex.

    Any ideas?
    Below is the javascript code,

    function OnClientClick_btnAdd()
    {
    var listReomveFrom = document.getElementById("ctl00$MainContent
    $ListBoxAvailable");
    var listAddTo= document.getElementById("ctl00$MainContent
    $ListBoxSelected");

    var iCurrentIndex = listReomveFrom.selectedIndex;
    var iNewOptionIndex = listAddTo.length;


    if (iCurrentIndex != -1)
    {
    listAddTo.options[iNewOptionIndex] = new Option();
    listAddTo.options[iNewOptionIndex].text =
    listReomveFrom.options[iCurrentIndex].text;
    listAddTo.options[iNewOptionIndex].value =
    listReomveFrom.options[iCurrentIndex].value;
    listAddTo.options[iNewOptionIndex].selected =
    listReomveFrom.options[iCurrentIndex].selected;
    listReomveFrom.options[iCurrentIndex --] = null;
    }
    }

    Thanks,
    Chandrasekar Balasubramaniam
     
    chandru, Jul 20, 2007
    #1
    1. Advertising

  2. chandru

    bruce barker Guest

    the browser only posts back the selected value(s) of a <select>, not the
    list. you will need to pass the changes back with some other method (say
    a hidden field).

    -- bruce (sqlwork.com)

    chandru wrote:
    > Hi,
    > I am adding some values to the ASP.NET ListControl on the client side
    > javascript
    > and this is not reflecting on the server side.
    > I thought the input and select fields should reflect the changes on
    > the server side.
    > I know that the post backs doesn't post all of the HTML only the
    > changes etc,etc.
    >
    > I am adding so many values to the list on the client side so I can't
    > have an hidden input field.
    > That will make things complex.
    >
    > Any ideas?
    > Below is the javascript code,
    >
    > function OnClientClick_btnAdd()
    > {
    > var listReomveFrom = document.getElementById("ctl00$MainContent
    > $ListBoxAvailable");
    > var listAddTo= document.getElementById("ctl00$MainContent
    > $ListBoxSelected");
    >
    > var iCurrentIndex = listReomveFrom.selectedIndex;
    > var iNewOptionIndex = listAddTo.length;
    >
    >
    > if (iCurrentIndex != -1)
    > {
    > listAddTo.options[iNewOptionIndex] = new Option();
    > listAddTo.options[iNewOptionIndex].text =
    > listReomveFrom.options[iCurrentIndex].text;
    > listAddTo.options[iNewOptionIndex].value =
    > listReomveFrom.options[iCurrentIndex].value;
    > listAddTo.options[iNewOptionIndex].selected =
    > listReomveFrom.options[iCurrentIndex].selected;
    > listReomveFrom.options[iCurrentIndex --] = null;
    > }
    > }
    >
    > Thanks,
    > Chandrasekar Balasubramaniam
    >
     
    bruce barker, Jul 20, 2007
    #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. Sumit
    Replies:
    1
    Views:
    327
    Rajesh.V
    Oct 16, 2003
  2. =?Utf-8?B?cGF0cmlja2RyZA==?=

    Client side changes not reflected in page

    =?Utf-8?B?cGF0cmlja2RyZA==?=, Feb 1, 2007, in forum: ASP .Net
    Replies:
    24
    Views:
    1,056
    =?Utf-8?B?cGF0cmlja2RyZA==?=
    Mar 28, 2007
  3. Patrice
    Replies:
    0
    Views:
    802
    Patrice
    Apr 12, 2010
  4. Joe Abou Jaoude
    Replies:
    2
    Views:
    178
    Joe Abou Jaoude
    Nov 18, 2004
  5. Gary Millar

    ASP Changes not reflected

    Gary Millar, Nov 11, 2003, in forum: ASP General
    Replies:
    2
    Views:
    143
    Ray at
    Nov 11, 2003
Loading...

Share This Page