Click here to Skip to main content
14,176,277 members
Rate this:
 
Please Sign up or sign in to vote.
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

just set autopostback property of checkboxlist to true.
and read checked box text and set to :
textbox.text=checkboxlist.selecteditem.text;
   
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190525.1 | Last Updated 13 Dec 2011
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100