asp.net - without - radiobuttonlist updatepanel not working




ASP.NET Radiobutton list set to autopostback but not posting back if selected item changes (2)

I have radiobuttonlist that i have set to autopostback, but when a user clicks a button, there is no postback.

Any suggestions?


I assume by "when a user clicks a button" you mean when a user clicks one of the radio button options. Without seeing any code, two common scenarios would be:

  1. A script error is occurring that is preventing the postback (script errors can be detected in IE or via Firefox and the Firebug extension as two diagnostic options)
  2. UpdatePanels are involved, and you are attempting to use the AutoPostBack to refresh an UpdatePanel

If it is the latter scenario and you are using UpdatePanels, try putting the RadioButtonList inside its own UpdatePanel, with AutoPostBack set to true on the RadioButtonList and the UpdateMode on the UpdatePanel set to "Always" (the default value).


I found that setting a radio button's Checked state to false for radio buttons belonging to a group cause a radio button with AutoPostBack="true" not to trigger a post-back.

For example:

Markup

<asp:RadioButton ID="radioButton1" runat="server" GroupName="Group1" AutoPostBack="true" OnCheckedChanged="radioButton1_Click" />
<asp:RadioButton ID="radioButton2" runat="server" GroupName="Group1" AutoPostBack="true" OnCheckedChanged="radioButton2_Click" />
<asp:RadioButton ID="radioButton3" runat="server" GroupName="Group1" AutoPostBack="true" OnCheckedChanged="radioButton3_Click" />

Code

protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    radioButton1.Checked = true;
    radioButton2.Checked = false; // don't do this!
    radioButton3.Checked = false; // don't do this!
  }
}

Leave the last two assignments out.





radio-button