Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > .NET Framework 1.x
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2006, 01:10 AM
Authorized User
 
Join Date: Mar 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to anup_daware Send a message via MSN to anup_daware Send a message via Yahoo to anup_daware
Default Problem with listbox at client side

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,
Client side code is like this ->

function assignInspector(listboxAllFieldEngineers,listBoxAs signedFieldEngineers)
        {
            i=0;
            while(i<listboxAllFieldEngineers.length)
            {
                if(listboxAllFieldEngineers.options[i].selected)
                {
                    var optn = document.createElement("OPTION");
                    optn.text = listboxAllFieldEngineers.options[i].value;
                    optn.value = listboxAllFieldEngineers.options[i].value;
                    listBoxAssignedFieldEngineers.options.add(optn);
                    listboxAllFieldEngineers.remove(i);
                    continue;
                }
                    i++;
            }
            return false;
        }



Here two list boxes are passed from .CS file ->

buttonAddSelected.Attributes.Add("onclick","return assignInspector(listboxAllFieldEngineers,listBoxAs signedFieldEngineers);");



PROBELM:-

Items move from one listbox to other perfectly but when listboxes are accessed through .cs file, they show there previous state,

e.g. ->

say LeftListBox is having 4 items and RightListBox is having 2 elements,
now I select and move two items from left and move them ro right and one of previously present items from right to left on button click,

the client side operation is carried out perfectly,

But when I try to use the Items in RightListBox in .CS file,RightListBox.Items.Count returns only '2' instead of '3', which are previously present in the RightListBox.


Please tell me where I am going wrong(Using ASP.NET 1.x).


Thanks and Regards,

Anup Daware


Best Regards,
Anup
&lt;Today is the first day of your rest of life.. Make most of it&gt;
__________________
--Everything you can imagine is real.--
 
Old May 23rd, 2006, 04:57 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

hi,

need to do a work around for this problem
Step : 1
Enable Multiple selection in second list box

step 2
in Javascript, after adding the new option to the list2, set the selected property as true for that option

step 3
in code behind[Cs file in your case] instead of accessing the second list as web server control, go through request object and pass the id there. You will get a comma seperated list of values.

Set 4
Split the list on "," and you will get the array of values in the second list box

BINGO!!

Anubhav Kumar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Converting Client-side to Server-side Code kwilliams ASP.NET 2.0 Professional 1 November 21st, 2007 05:25 PM
problem with client side code thenoseknows ASP.NET 2.0 Professional 5 September 12th, 2006 09:08 AM
Problem with client side script cschng Classic ASP Basics 2 May 23rd, 2005 12:43 AM
Client & Server Side Scripting Problem lbob Classic ASP Professional 0 October 16th, 2003 10:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.