- User code after bind the checkboxlist in C#
- -----------------------------------------------------------------------------
- foreach (ListItem item in checkBoxList.Items)
- {
- item.Attributes.Add("hiddenValue", item.Value);
- }
- -----------------------------------------------------------------------------
- JQuery
- ----------------------------------------------------------------------------
- $(document).ready(function (){
- $("#button").click(function (){
- $("#ctl00_ContentPlaceHolder1_checkBoxList").val('');
- var list=""; var item="";
- $("[id*=checkBoxList] input:checked").each(function () {
- if(list=='')
- list+=$(this).parent().attr('hiddenValue')
- else
- list+=", "+$(this).parent().attr('hiddenValue')
- });
- $("#ctl00_ContentPlaceHolder1_txtValue").val(all);
- });
- $("#addBtn").click(function (){
- $("#ctl00_ContentPlaceHolder1_txtRadio").val('');
- var item= $('#ctl00_ContentPlaceHolder1_radioButtonList input[type=radio]:checked').val();
- $("#ctl00_ContentPlaceHolder1_txtRadio").val(item);
- });
- });
This code snippet for Get RadioButtonList and CheckBoxList Value using jQuery inASP.NET.
