473,505 Members | 14,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox selection fails

2 New Member
Hi everybody

I have a javascript to select and deselect items in a listbox depending on checkbox selection

The problem now i have is, i am calling the javascript from server side

What happens is as the listbox 1 get populated, and selected with checkbox selection in my application,

i have a button which refreshes the page thereby populating listbox2, with reference to the items selected in listbox1

So what is happening is,
- the user selects checkall-- all items get selected

- the user hits the refresh button -- all the items deselected and also checkbox is marked unchecked


Hope you can understand my issue
Please help me to fix this issue

I am using VB.net (.net 2.0)

Thanks to all
Jun 14 '07 #1
4 1499
shweta123
692 Recognized Expert Contributor
Hi,

I am not clear with your question. What is the Expected result and what error are you getting?


Hi everybody

I have a javascript to select and deselect items in a listbox depending on checkbox selection

The problem now i have is, i am calling the javascript from server side

What happens is as the listbox 1 get populated, and selected with checkbox selection in my application,

i have a button which refreshes the page thereby populating listbox2, with reference to the items selected in listbox1

So what is happening is,
- the user selects checkall-- all items get selected

- the user hits the refresh button -- all the items deselected and also checkbox is marked unchecked


Hope you can understand my issue
Please help me to fix this issue

I am using VB.net (.net 2.0)

Thanks to all
Jun 16 '07 #2
kenobewan
4,871 Recognized Expert Specialist
You are able to refresh only part of the page using a panel. HTH.
Jun 18 '07 #3
prabunewindia
199 New Member
i didn't get what is need.
u explained what u r getting now. but not ur need.
plz paste the code also
Prabu

Hi everybody

I have a javascript to select and deselect items in a listbox depending on checkbox selection

The problem now i have is, i am calling the javascript from server side

What happens is as the listbox 1 get populated, and selected with checkbox selection in my application,

i have a button which refreshes the page thereby populating listbox2, with reference to the items selected in listbox1

So what is happening is,
- the user selects checkall-- all items get selected

- the user hits the refresh button -- all the items deselected and also checkbox is marked unchecked


Hope you can understand my issue
Please help me to fix this issue

I am using VB.net (.net 2.0)

Thanks to all
Jun 18 '07 #4
HKS
2 New Member
Thank to all for the replies
The code which i am using is

Expand|Select|Wrap|Line Numbers
  1. function onChange(checkBoxRef,listboxId)
  2.         {
  3.  
  4.             var listboxRef = document.getElementById(listboxId)
  5.  
  6.             if(checkBoxRef.checked)
  7.  
  8.             {
  9.  
  10.                for (var i=0;i<listboxRef.options.length;i++)
  11.  
  12.  
  13.                 {
  14.  
  15.                     listboxRef.options[i].selected = true;
  16.  
  17.                 }
  18.             }
  19.             else
  20.  
  21.             {
  22.  
  23.                for (var i=0; i<listboxRef.options.length; i++)
  24.  
  25.                 {
  26.  
  27.                   listboxRef.options[i].selected = false;
  28.  
  29.                 }
  30.             }
  31.         }
  32.  
  33.          function removeCheck(checkboxId)
  34.         {
  35.             document.getElementById(checkboxId).checked = false;
  36.         }
  37.  
  38.  
  39.  
And in code behind
Expand|Select|Wrap|Line Numbers
  1. lstAccounts.Attributes.Add("onChange", "javascript:removeCheck('" + chkAll.ClientID + "');")
  2.         chkAll.Attributes.Add("onClick", "javascript:onChange(this, '" + lstAccounts.ClientID + "');")
  3.  
  4.  
This code works fine.
Here suppose the listbox items selected and checkbox is checked,
I have another button clcik event
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.     DataBindListbox2()
  3.  
  4.     End Sub
  5.  
When i hit this button, all the selection of lstacounts is gone and also the checkbox check
How can i reselect the lstaccounts and checkbox, coz Databindlistbox2 is based on lstaccounts selected items
Hope i am more clear now
I tried a lot, but not able to figure out
Please help me

Thanks
Jun 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
6794
by: (Pete Cresswell) | last post by:
Seems like I've been here before, but can't find anyting in Google. I've got two list boxes on a form. Seems to me like the inactive ListBox's selection rectangle should be something like...
6
29980
by: Dan Bass | last post by:
If you look at explorer, right clicking on a file, first selects the file, then throws up the context menu relating to that selection. With a Windows ListBox control and a simple context menu,...
6
12888
by: Alpha | last post by:
I have a listbox with datasource from a dataview. When a user selects a different item in a combobox then I need to refresh the listbox to the appropriate listing based on that combobox's selected...
6
2858
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
5
3513
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
5
2286
by: Dave H | last post by:
I have an asp:listbox, allowing multiple selections, is there a quick check to see if there's more than one selected, or do I need to go through the whole list? Thanks, Dave
0
1327
by: Sanjin | last post by:
I have populated listbox with data from the datatable. I binded SelectedValue to the another datatable - i.e. selection result (with VS 20005 wizard). Selection result datatable has...
9
3200
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
4
1432
by: kimiraikkonen | last post by:
Hi, I have a odd but a known question about listbox. I know listbox control can provide multi-select, multi-extendend selections. But i wonder if this selection type belongs to them or it has...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.