title: Getting value in C# code behind from an asp:DropDownList populated with Ajax
body: <p>I have 2 DropDownLists which are populated in c# code before the page is rendered. When the page is posted back I can successfully get the changed values.  However, one condition is if the value changes in the first DropDownList I repopulate the second drop down list.  I am doing this using an Ajax call and everything is visually working well.</p>
  
  <p>The problem is when the condition arises that the second DropDownList is populated via Ajax code the list items and selected values are not being shown back in the C# code when posted back.  I have read that this will NOT happen.</p>
  
  <p>The DropDownList has an <code>ID="cboMutations"</code></p>
  
  <p>I have finally got this working using the following method:</p>
  
  <pre><code>        Int32 id = 0;
          if (!string.IsNullOrEmpty(Request.Form["ctl00$MainContent$cboMutations"]))
          {
              Int32.TryParse(Request.Form["ctl00$MainContent$cboMutations"], out id);
          }
  </code></pre>
  
  <p>My main questions are:</p>
  
  <p>Is this safe to use <code>ctl00$MainContent$cboMutations</code> to reference the property in this manner? </p>
  
  <p>It works in development, but will it work when deployed?</p>