Thanks for the reply to bothI am using server controls onlyI enabled viewstate to trueWhat i have now is function onChange(checkBoxRef,listboxId) { var listboxRef = document.getElementById(listboxId) if(checkBoxRef.checked) { for (var i=0;i<listboxRef.options.length;i++) { listboxRef.options[i].selected = true; } } else { for (var i=0; i<listboxRef.options.length; i++) { listboxRef.options[i].selected = false; } } } function removeCheck(checkboxId) { document.getElementById(checkboxId).checked = false; }
And in code behind lstAccounts.Attributes.Add("onChange", "Javascript:removeCheck('" + chkAll.ClientID + "');") chkAll.Attributes.Add("onClick", "javascript:onChange(this, '" + lstAccounts.ClientID + "');")
This code works fine.Here suppose the listbox items selected and checkbox is checked, I have another button clcik event Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click DataBindListbox2() End Sub
When i hit this button, all the selection of lstacounts is gone and also the checkbox checkHow can i reselect the lstaccounts and checkbox, coz Databindlistbox2 is based on lstaccounts selected itemsI tried a lot, but not able to figure outPlease help meThanks