Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET Listbox Client Side changes not reflected on page

Reply
Thread Tools

ASP.NET Listbox Client Side changes not reflected on page

 
 
chandru
Guest
Posts: n/a
 
      07-20-2007
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

 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      07-20-2007
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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changes in DB Value not Reflected in Output John Smith Java 3 02-01-2011 10:47 PM
Re: Changes in aspx page not reflected on production site Patrice ASP .Net 0 04-12-2010 08:45 AM
Client side changes not reflected in page =?Utf-8?B?cGF0cmlja2RyZA==?= ASP .Net 24 03-28-2007 02:04 AM
listbox changes on the client side aren't reflected on the server side Joe Abou Jaoude ASP .Net Web Controls 2 11-18-2004 12:21 PM
client side scripting changes to be reflected back to server Sumit ASP .Net 1 10-16-2003 04:17 PM



Advertisments