Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8627645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:19:56+00:00 2026-06-12T08:19:56+00:00

I have a asp.net checkbox list that is dynamically generated and I need to

  • 0

I have a asp.net checkbox list that is dynamically generated and I need to process some code if the checkbox was initially checked and is unchecked.

This needs to be done in Jquery or Javascript.

All the examples I see deal with getting all values of “Checked” I am only interested in getting the specific item that triggered the onClick() event’s ID so that I can run some other code to process it.

public void DrawPoolWeekCbList()
{
    var poolWeeks = ControllerFacade.GetAllPoolWeeksByPoolYear(PageView.PoolWeekYear.Text);
    var pWeekCount = poolWeeks.Count;
    var curRecord = 0;
    foreach (var poolWeek in poolWeeks)
    {
        PageView.cblPoolWeeks.Items.Add(poolWeek);
        PageView.cblPoolWeeks.Items[curRecord].Attributes.Add("onclick", "OnCheckBoxClicked("+ poolWeek +")");
        curRecord++;
    }
}

//UI Code
function OnCheckBoxClicked(poolWeek) {
    var chkId = poolWeek.toString();
    $('#<%= lblPoolWeekChange.ClientID %>').text(chkId);
    $(".addNew").dialog("open");
}

All the samples I have seen find ALL checked checkboxes and loop through them all, again I just want the SPECIFIC checkboxes id that triggered the function.

Thanks!

//Generated HTML - 
<input id="ContentPlaceHolder1_cblPoolWeeks_0" type="checkbox" name="ctl00$ContentPlaceHolder1$cblPoolWeeks$0" onclick="OnCheckBoxClicked(01);" value="01" /><label for="ContentPlaceHolder1_cblPoolWeeks_0">01</label></td><td><input id="ContentPlaceHolder1_cblPoolWeeks_1" type="checkbox" name="ctl00$ContentPlaceHolder1$cblPoolWeeks$1" onclick="OnCheckBoxClicked(02);" value="02" /><label for="ContentPlaceHolder1_cblPoolWeeks_1">02</label></td><td><input id="ContentPlaceHolder1_cblPoolWeeks_2" type="checkbox" name="ctl00$ContentPlaceHolder1$cblPoolWeeks$2" onclick="OnCheckBoxClicked(03);" value="03" /><label for="ContentPlaceHolder1_cblPoolWeeks_2">03</label>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:19:58+00:00Added an answer on June 12, 2026 at 8:19 am

    This snippet worked for me, keep in mind there is only one CheckBoxList on the asp.net page, if there was more than one this might not work – Keep in mind this is for handling a SINGLE checkbox and not for iterating through as in “CHECK ALL” functionality. This is handy if you need to add all checked values to a session variable(My case) for a later update of the records.

       $(document).ready(function () {
           $("input:checkbox").click(function () {
               if ($(this).is(":checked")) {
                   OnCheckBoxClicked(this.value);
               } else {
                   OnUnchecked(this.value);
               }
           });
       }); 
    
       function OnCheckBoxClicked(poolWeek) {
    
           var chkId = poolWeek.toString();
           //Show DialogBox - Set label to pool week.
           $('#<%= lblPoolWeekChange.ClientID %>').text(chkId);
           $(".addNew").dialog("open");
    
       }
    
       function OnUnchecked(poolWeek) {
           var chkId = poolWeek.substring(2, 4);
           var commodity = $('#<%= Commodity.ClientID %> option:selected').text();
           $.ajax(
                    {
                        type: "POST",
                        url: "Ajax/DeleteExcludedPoolWeek.aspx",
                        data: "poolWeek=" + chkId +  "&commodity=" + commodity,
                        success: function (msg) {
                            $('#myDiv').text('Pool week status changed.');
    
                        },
                        error: function (x, e) {
                            alert("The call to the server side failed. " + x.responseText);
                        }
                    }
                );
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an ASP.Net page that uses a checkbox to toggle between a list
Hi All I need a CheckBox Dropdown list control in asp.net i have seen
I have a checkbox list control on my asp.net web form that I am
I have a custom control that mimics to some extent the built in ASP.Net
I have a product admin web site that has been generated using ASP.NET Dynamic
I have an Asp.Net page with a list of options accompanied by a checkbox
In ASP.NET, I have collected a list of selected items from a checkbox in
I have an ASP.NET login control on a page, with the Remember Me checkbox
in a ASP.net C# application I have a Checkbox with a custom css. the
I have ASP.NET page with an iframe on it for displaying some pdf reports

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.