title: RadioButtonList set in PreLoad causes UpdatePanel Trigger to not fire when set back to initial value
body: <p>We had some "strange" issues when using UpdatePanels and RadioButtonLists in that a PostBack was not occuring when you changed the values.</p>
  
  <p>I've managed to track down the issue in that it occurs when the value of the RadioButtonList is set in the PreLoad of a page and you are re-selecting this initial value.</p>
  
  <p>I have the full code of the ASP page and the CodeBehind below.</p>
  
  <p>ASPX:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RBLPostBackIssue._Default" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Untitled Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;&lt;/asp:ScriptManager&gt;
      &lt;div&gt;
      &lt;asp:Label ID="Label1" runat="server"&gt;&lt;/asp:Label&gt;
      &lt;asp:RadioButtonList ID="RadioButtonList1" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" RepeatDirection="Horizontal" runat="server"&gt;
          &lt;asp:ListItem&gt;Yes&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;No&lt;/asp:ListItem&gt;
      &lt;/asp:RadioButtonList&gt;
      &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
          &lt;ContentTemplate&gt;
              &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt;
                  &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/asp:PlaceHolder&gt;
          &lt;/ContentTemplate&gt;
          &lt;Triggers&gt;
              &lt;asp:AsyncPostBackTrigger ControlID="RadioButtonList1" EventName="SelectedIndexChanged" /&gt;
          &lt;/Triggers&gt;
      &lt;/asp:UpdatePanel&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>CodeBehind:</p>
  
  <pre><code>using System;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  namespace RBLPostBackIssue
  {
      public partial class _Default : System.Web.UI.Page
      {
          protected void Page_PreLoad(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  switch (new Random().Next(2))
                  {
                      case 0:
                          Label1.Text = "Initial value set to Yes";
                          RadioButtonList1.SelectedValue = "Yes";
                          break;
                      case 1:
                          Label1.Text = "Initial value set to No";
                          RadioButtonList1.SelectedValue = "No";
                          break;
                  }
              }
          }
  
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  ShowHideLogic();
              }
          }
  
          private void ShowHideLogic()
          {
              PlaceHolder1.Visible = RadioButtonList1.SelectedValue.ToLower().Contains("yes");
          }
  
          protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
          {
              ShowHideLogic();
          }
      }
  }
  </code></pre>
  
  <p>The following occurs.</p>
  
  <ul>
  <li>The first load the RadioButtonList is set randomly to Yes or No.</li>
  <li>You change the value of the RadioButtonList and the textbox will show/hide accordingly.</li>
  <li>You change the value back to it's original value and no postback occurs at all.</li>
  <li>No matter how often you change the value a postback will only occur if you do NOT select the initial value.</li>
  </ul>
  
  <p>The setting of the inital value in the PreLoad comes from some legacy code that we would prefer not to change. Any change there will require a substantial amount of testing and re-deploying to a large number of other projects.</p>
  
  <p>The only solution I have found is to not use a Trigger for the RadioButtonList but to put it within the UpdatePanel. Whislt this is a solution in some cases, it is not ideal as UI does not allways allow this.</p>
  
  <p>I guess my question is, has anyone else had this problem, do you know of another solution to it, or am I just being stupid and have missed something obvious?</p>