title: Full postback triggered by LinkButton inside UpdatePanel
body: <p>I'm having trouble dynamically adding controls inside an update panel with partial postbacks.I generate some LinkButton dynamically in code behind and set trigger of them, but when I fire them they full postback, even LinkButton Event does not get called when I fire them.They are placed in the 'divPageNumber'</p>
  
  <p>*.aspx:</p>
  
  <pre><code>&lt;/asp:DataList&gt;
                 &lt;table style="width: 100%"&gt;
                     &lt;tr style="width: 10%"&gt;
                         &lt;td&gt;
                             &lt;asp:LinkButton ID="lnkPrevious" runat="server" Font-Bold="True"
                                 NavigateUrl="~/Default.aspx" OnClick="lnkPrevious_Click" Width="100px"&gt;&amp;lt;&amp;lt;صفحه قبل&lt;/asp:LinkButton&gt;
                         &lt;/td&gt;
                         &lt;td style="width: 80%"&gt;
                             &lt;div id="divPageNumber" dir="rtl" runat="server"&gt;
                             &lt;/div&gt;
                         &lt;/td&gt;
                         &lt;td style="width: 10%"&gt;
                             &lt;asp:LinkButton ID="lnkNext" runat="server" Font-Bold="True"
                                 NavigateUrl="~/Default.aspx" OnClick="lnkNext_Click" Width="80px"&gt;صفحه بعد&amp;gt;&amp;gt;&lt;/asp:LinkButton&gt;
                         &lt;/td&gt;
                     &lt;/tr&gt;
                 &lt;/table&gt;
             &lt;/ContentTemplate&gt;
             &lt;Triggers&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton1" EventName="Command"&gt;&lt;/asp:AsyncPostBackTrigger&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton2" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton3" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton4" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton5" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton6" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton7" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton0" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="btnSearchHead" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="LinkButton8" EventName="Command" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="lnkNext" EventName="Click" /&gt;
                 &lt;asp:AsyncPostBackTrigger ControlID="lnkPrevious" EventName="Click" /&gt;                   
             &lt;/Triggers&gt;
  
         &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>and *.cs:</p>
  
  <pre><code>LinkButton btnPage;
              for (int i = 1; i &lt;= objPagedDataSource.PageCount; i++)
              {
                  btnPage = new LinkButton();                    
                  btnPage.ID = "btnPage" + i.ToString();                    
                  if (i == GetCurrentPageNumber + 1)
                      btnPage.Font.Bold = true;
                  btnPage.Width = 10;
                  btnPage.Style["margin-right"] = "2px";
                  btnPage.Style["margin-left"] = "2px";
                  btnPage.Text = i.ToString();
  
                  if (brand != "" &amp;&amp; brand != null)
                      btnPage.PostBackUrl = "Default.aspx?brand=" + brand + "&amp;Page=" + i.ToString();
                  else if (model != "" &amp;&amp; model != null)
                      btnPage.PostBackUrl = "Default.aspx?model=" + model + "&amp;Page=" + i.ToString();
                  else
                      btnPage.PostBackUrl = "Default.aspx?Page=" + i.ToString();
  
                  divPageNumber.Controls.Add(btnPage);
  
                  LinkButton lb = (LinkButton)divPageNumber.FindControl("btnPage" + i.ToString());
                  lb.Click += new EventHandler(lnkdel_OnClick);
  
                  //Creates a new async trigger
                  AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
                  trigger.ControlID = lb.UniqueID;
                  trigger.EventName = "Click";
                  UpdatePanel1.Triggers.Add(trigger);
  
                  ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb);
              }
              UpdatePanel1.Update();
  
  protected void lnkdel_OnClick(object sender, EventArgs e)
      {
  
      }
      protected void lnkPrevious_Click(object sender, EventArgs e)
      {
          //GetCurrentPageNumber -= 1;
          //BindDataToRepeter();
          Response.Redirect("Default.aspx?Page=" + (Convert.ToInt32(Page.Request["Page"]) - 1).ToString());
      }
      protected void lnkNext_Click(object sender, EventArgs e)
      {
          //GetCurrentPageNumber += 1;
          //BindDataToRepeter();
  
          Response.Redirect("Default.aspx?Page=" + (Convert.ToInt32(Page.Request["Page"]) + 1).ToString());
      }
  </code></pre>
  
  <p>'lnkNext' and 'lnkPrevious' is static added and work. but 'lnkdel_OnClick' doesn't work.</p>
  
  <p>What am I doing?</p>
  
  <p>thanks</p>