Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a combobox and a checkboxlist where the options in the checkboxlist change when the user selects the options in the combobox.
I also have a textbox under the both wherein I want to get the item which the user has selected from the checkboxlist. I am not able to get a onclick event for CheckBoxList. Can anyone help?
Posted
Comments
raj ch 14-Dec-11 2:21am    
Have u set the autoPostBack Event of the checkbox true.

just set autopostback property of checkboxlist to true.
and read checked box text and set to :
textbox.text=checkboxlist.selecteditem.text;
 
Share this answer
 
Comments
gpthakur 13-Dec-11 4:53am    
my question is, On which event of the Checkbox do I write the above code since I am not getting a onclick event for it
Hi,
jquery has some easy tech to do such kind of tasks, this might give you some idea to solve your problem

<script>
$(function () {
$('.checkboxlist1').click(function (e) {
var txt = $(this).text();
$('#textbox1').val(txt);
});
});
</script>

you need to add the <a href="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js">jquery reference</a> file in the header of your page
 
Share this answer
 
Comments
gpthakur 13-Dec-11 5:47am    
Not able to find the control in the document. I tried by modifying the code since in my earlier jquery I used a different method to access the controls.

$(function ()
{
$("#CheckBoxList1").click(function (e)
{
alert('hi');
var txt = $(this).text();
alert(txt);
$("#txtAllergyName").val(txt);
}
);
}
);
tanweer 13-Dec-11 6:01am    
this is happen when there is master page associated with it. please right click the page and open the source html and see the control ID there, copy it and replace CheckBoxList1 and txtAllergyName in the above script

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900