MS Ajax: RadioButton CheckedChanged not firing back with AJAX v1.0?

I saw a very interesting post on the Ajax forum. NXTwoThou had a problem with 2 radiobutton controls which must fire the OnCheckedChanged event. Here is the code.

        <script runat=”Server”>
            protected void Page_Load(object sender, EventArgs e)
                if (!IsPostBack)
                    ddl_customers_specific.Items.Add(new ListItem(“Test”));
            protected void rb_customers_all_CheckedChanged(object sender, EventArgs e)
                ddl_customers_specific.BackColor = System.Drawing.Color.Red;
            protected void rb_customers_specific_CheckedChanged(object sender, EventArgs e)
                ddl_customers_specific.BackColor = System.Drawing.Color.Blue;
        <form id=”form1″ runat=”server”>
            <asp:ScriptManager runat=”server” ID=”sm” />
                 <asp:RadioButton ID=”rb_customers_all” runat=”server” Text=”All Customers” AutoPostBack=”true”
                 Checked=”true” GroupName=”g_Customers” OnCheckedChanged=”rb_customers_all_CheckedChanged” />        
    <asp:RadioButton ID=”rb_customers_specific” runat=”server” Text=”Specific Customers” AutoPostBack=”true” GroupName=”g_Customers” OnCheckedChanged=”rb_customers_specific_CheckedChanged” />
    <asp:UpdatePanel ID=”up_customer” runat=”server” UpdateMode=”conditional”>
                          <asp:DropDownList ID=”ddl_customers_specific” runat=”server” />
                          <asp:AsyncPostBackTrigger ControlID=”rb_customers_all” EventName=”CheckedChanged” />
                          <asp:AsyncPostBackTrigger ControlID=”rb_customers_specific” EventName=”CheckedChanged” />


The problem is that the radio button “rb_customers_all” has the property checked set to true. When this is set to true the event will never get fired. removing this property and adding the following code “rb_customers_all.InputAttributes[“checked”] = “true”;” will fix this problem.

Have fun!


11 Responses to MS Ajax: RadioButton CheckedChanged not firing back with AJAX v1.0?

  1. michel says:

    Having a similar issue with radio button lists. The above solution modified for a list “rbList.Items[0].Attributes{“checked”] = “true” doesn’t quite work as it creates a span with a “checked” attribute?

  2. Dennis says:

    Hi michel,
    Can you email ( your code to me then i can take a look at it this weekend.

  3. Amar says:

    Thanks for the post. It helped me out of a situation.
    But what is the difference between

    rb_customers_all.InputAttributes[”checked”] = “true”;
    rb_customers_all.Checked = true;

    Thanks again.

  4. Mark Aurit says:

    Wish Id of seen this before I spent some serious time trying to figure out why the events stopped firing.

  5. Sandeep Acharya says:


    The InputAttributes[”checked”] approach helped me to get rid of the CheckChanged issue. It is working fine for me.



  6. Sandeep Acharya says:

    But there is only one problem. Setting the checked attribute to true by using InputAttributes[”checked”] approach is not setting the btn.Checked to true.

    Can any one tell me how to solve this.



  7. dennisv says:

    Hi Sandeep,

    Do you mean that when you want to “check” if the checkbox is checked in the codebehind this isn’t available?

    btn = a checkbox in your situation i believe


  8. Dennis Fack says:

    I think Sandeep is right.
    If you want init the RadioButton with “RadioButton1.Checked = true” the “fix” don’t work.

  9. Andrew says:

    Hi Thanks dennisv

    That solved my problem. Not the easist thing to get working when you would expect the CheckedChanged to just work.

    Thanks again


  10. Nick says:

    Thanks! Wierd issue but your solution works!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: