title: Different control is assigned to the same ID after postback - ASP.NET
body: <p>I have recently updated one of my old ASP.NET applications from .NET 2.0 to .NET 4.5 and it was one of the first applications where I attempted to use the <code>asp:UpdatePanel</code> control.  It is a survey application where a user can create a survey, assigned multiple question groups to the survey and multiple questions types to each question group.</p>
  
  <p>When I use the page where a user can edit the survey content that contains <code>AsyncPostBackTrigger</code> objects that are registered to <code>LinkButton</code> asp.net controls in question type user controls registered on the page, I get the following error:</p>
  
  <blockquote>
    <p>Error: Sys.WebForms.PageRequestManagerServerErrorException: An error
    has occurred because a control with id
    'ctl00$PageBody$gvSurveyQuestions$ctl02$ctl03' could not be located or
    a different control is assigned to the same ID after postback. If the
    ID is not assigned, explicitly set the ID property of controls that
    raise postback events to avoid this error.</p>
  </blockquote>
  
  <p>The user control is dynamically generated based on which control the user selected to be part of the group.  In the <code>OnRowCommand</code> event of the <code>DataGrid</code> control, it determined which user control to display based on the type of question selected.  Here is a snippet of code:</p>
  
  <p>survey ASPX page:</p>
  
  <pre><code>//grid control to allow user to select the question to edit
  &lt;asp:GridView ID="gvSurveyQuestions" runat="server" AutoGenerateColumns="false" 
      OnRowCommand="gvSurveyQuestions_OnRowCommand" 
      OnRowEditing="gvSurveyQuestions_OnRowEditing" 
      OnRowDeleting="gvSurveyQuestions_OnRowDeleting" 
      CssClass="com_grid"
      Width="100%" 
      CellPadding="3" 
      CellSpacing="0"
  &gt;
      &lt;asp:CommandField ButtonType="Link" ShowEditButton="True" ShowDeleteButton="True" 
          ItemStyle-HorizontalAlign="Center" /&gt;
  &lt;/asp:GridView&gt;
  &lt;asp:PlaceHolder ID="phEditExcellentPoor" runat="server" Visible="false"&gt;
      &lt;tr&gt;
          &lt;td width="100%"&gt;
              &lt;uc:ExcellentPoor Id="ucEditExcellentPoor" runat="server" EditMode="Edit" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/asp:PlaceHolder&gt;
  </code></pre>
  
  <p>Code Behind of ASPX page:</p>
  
  <pre><code>private readonly string m_CreateUpdateQuestionControlName = "lbCreateUpdateQuestion";
  private readonly string m_CreateUpdateQuestionText_Edit = "Update Question";
  
  protected void Page_Init(object sender, EventArgs e)
  {
      //here is the code to set the async postback trigger
      AsyncPostBackTrigger apExcellentPoorEdit = new AsyncPostBackTrigger();
      apExcellentPoorEdit.ControlID = ucEditExcellentPoor.FindControl(this.m_CreateUpdateQuestionControlName).UniqueID;
      upSurveyQuestions.Triggers.Add(apExcellentPoorEdit);
  }
  </code></pre>
  
  <p>Code behind of user control to set link button as postback trigger on the survey ASPX page:</p>
  
  <pre><code>public event EventHandler lbCreateUpdateQuestionClick;
  
  protected void lbCreateUpdateQuestion_OnClick(object sender, EventArgs e)
  {
      if (this.lbCreateUpdateQuestionClick != null)
          this.lbCreateUpdateQuestionClick(sender, e);
  }
  </code></pre>
  
  <p>Why I am getting this error and what would be some good suggestions to look where to fix it?</p>