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 6318441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:38:18+00:00 2026-05-24T15:38:18+00:00

I have a CheckBox on an ASP.NET Content Form like so: <asp:CheckBox runat=server ID=chkTest

  • 0

I have a CheckBox on an ASP.NET Content Form like so:

<asp:CheckBox runat="server" ID="chkTest" AutoPostBack="true" OnCheckedChanged="chkTest_CheckedChanged" />

In my code behind I have the following method:

protected void chkTest_CheckedChanged(object sender, EventArgs e)
{
}

When I load the page in the browser and click the CheckBox it becomes checked, the page posts back, and I can see chkTest_CheckedChanged being called.

When I then click the CheckBox again it becomes unchecked, the page posts back, however chkTest_CheckedChanged is not called.

The process is repeatable, so once the CheckBox is unchecked, checking it will fire the event.

I have View State disabled in the Web.Config, enabling View State causes this issue to disappear. What can I do to have reliable event firing while the View State remains disabled?

Update:
If I set Checked="true" on the server tag the situation becomes reversed with the event firing when un-checking the CheckBox, but not the other way around.

Update 2:
I’ve overridden OnLoadComplete in my page and from within there I can confirm that Request.Form["__EVENTTARGET"] is set correctly to the ID of my CheckBox.

  • 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-24T15:38:19+00:00Added an answer on May 24, 2026 at 3:38 pm

    Implementing a custom CheckBox that stores the Checked property in ControlState rather than ViewState will probably solve that problem, even if the check box has AutoPostBack=false

    Unlike ViewState, ControlState cannot be disabled and can be used to store data that is essential to the control’s behavior.

    I don’t have a visual studio environnement right now to test, but that should looks like this:

    public class MyCheckBox : CheckBox
    {
        private bool _checked;
    
        public override bool Checked { get { return _checked; } set { _checked = value; } }
    
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            //You must tell the page that you use ControlState.
            Page.RegisterRequiresControlState(this);
        }
    
        protected override object SaveControlState()
        {
            //You save the base's control state, and add your property.
            object obj = base.SaveControlState();
    
            return new Pair (obj, _checked);
        }
    
        protected override void LoadControlState(object state)
        {
            if (state != null)
            {
                //Take the property back.
                Pair p = state as Pair;
                if (p != null)
                {
                    base.LoadControlState(p.First);
                    _checked = (bool)p.Second;
                }
                else
                {
                    base.LoadControlState(state);
                }
            }
        }
    }
    

    more info here.

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

Sidebar

Related Questions

So - I have a checkbox <asp:CheckBox ID=chkOrder runat=server Visible='<%#IsCheckBoxVisible() %>' Checked=false OnCheckedChanged=chkOrder_CheckedChanged AutoPostBack=true
I have some ASP.Net code that defines a server-side checkbox like this: <asp:CheckBox ID=_chkWindAndHail
I have a Repeater (ASP.Net). <asp:Repeater ID=rep runat=server> <ItemTemplate> <asp:TextBox runat=server ID=txt></asp:TextBox> <asp:CheckBox runat=server
I have following ASP.NET server control checkboxes. <asp:checkbox id=chkMonS1 runat=server /> <asp:checkbox id=chkMonS2 runat=server
I have a checkbox list control on my asp.net web form that I am
We have an ASP.Net page that uses a checkbox to toggle between a list
I have an Asp.Net repeater, which contains a textbox and a checkbox. I need
I have an ASP.NET login control on a page, with the Remember Me checkbox
I have a Gridview <asp:GridView ID=GridView1 runat=server Width=400px AutoGenerateColumns=false OnSelectedIndexChanged=GridView1_SelectedIndexChanged1> <Columns> <asp:TemplateField> <ItemTemplate> <asp:CheckBox
I have an ASP.NET checkbox, and I want to run some javascript before it

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.