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

  • Home
  • SEARCH
  • 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 382781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:13:08+00:00 2026-05-12T15:13:08+00:00

I have a UserControl that contains a CheckBox and a TextBox: <asp:CheckBox runat=server ID=chk1

  • 0

I have a UserControl that contains a CheckBox and a TextBox:

<asp:CheckBox runat="server" ID="chk1" />
<asp:TextBox runat="server" ID="tb1" />

On Page_Load I’m adding several of them dynamically them to a Panel on the page:

 //loop through the results from DB
 foreach (Thing t in Things)
 {
    //get the user control
    MyUserControl c1 = (MyUserControl )Page.LoadControl("~/UserControls/MyUserControl.ascx");

    //set IDs using public properties
    c1.ID = "uc" + t.ID;
    c1.CheckBoxID = "chk" + t.ID;
    cl.TextBoxID = "tb" + t.ID;

    //add it to the panel
    myPanel.Controls.Add(c1);

    //add the event handler to the checkbox
    ((CheckBox)myPanel.FindControl(c1.ID).FindControl(c1.CheckBoxID)).CheckedChanged += new EventHandler(CheckBox_CheckedChanged);   
 }

I then created the method for the event handler in the same page:

protected void CheckBox_CheckedChanged(object sender, EventArgs e)
{
       string test = "breakpoint here";
}

When I put a breakpoint inside CheckBox_CheckedChanged it’s never hit when the my checkbox gets clicked.

When I look at the view source, this is the code that gets generated:

<input id="ctl00_body_uc1_chk1" type="checkbox" name="ctl00$body$uc1$chk1" checked="checked" />

So, it doesn’t seem to be picking up when I add the event handler. It’s weird, cause it picks up everything else though.

Am I missing something?

  • 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-05-12T15:13:09+00:00Added an answer on May 12, 2026 at 3:13 pm

    “When I put a breakpoint inside CheckBox_CheckedChanged it’s never hit when the my checkbox gets clicked.”

    If you want the event to fire when the check box gets clicked, you also need to set AutoPostBack = true on the check box. If you put the cursor in the text box and press return (causing a post back), does the event fire?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Web User Control that contains a CheckBoxList. MyListControl: <asp:checkboxlist id=chkList runat=server>
I have a UserControl that contains a TextBox. The TextBox.Text property is data-bound and
I have a usercontrol that is in an asp.net page that contains a button.
I have a custom UserControl that contains just one TextBox . When I set
I have a custom UserControl which contains several TextBoxes with Validators. One TextBox with
I have an assembly which contains several UserControl objects that I want to be
I have an asp.net usercontrol that contains a jQuery UI Dialog Control. All works
I have a TabControl that contains several tabs. Each tab has one UserControl on
I have created my first asp.net UserControl that I will use in several places
I have an ASP.Net web user control that contains a TextBox and a calendar

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.