By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

Listbox selection fails

P: 2
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
Share this Question
Share on Google+
4 Replies


shweta123
Expert 100+
P: 692
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
Expert 2.5K+
P: 4,871
You are able to refresh only part of the page using a panel. HTH.
Jun 18 '07 #3

prabunewindia
100+
P: 199
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

P: 2
HKS
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

Post your reply

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