How to do AsyncPostBackTrigger for the LinkButton in the Repeater

I had similar problem, but I didn't want to update the whole repeater, only a content outside of the repeater... so what I did was

1. Add the repeater

<asp:Repeater ID="productList" runat="server">
  <!-- my repeater -->
<asp:Repeater>

2. Add the Update Panel with the updatable content, and the trigger

<asp:UpdatePanel ID="up" runat="server">
    <ContentTemplate>
        <!-- when click on repeater's links, this content will be updated -->
    </ContentTemplate>
    <Triggers>
        <!-- trigger will be the repeater's links/btn that generate postback -->
        <asp:AsyncPostBackTrigger ControlID="productList" />
    </Triggers>
</asp:UpdatePanel>

Adding the following attribute to the page directive containing the repeater and linkbutton will also work:

<%@ page ClientIDMode="AutoID" %>

I had a control that needed to work both asynchronously and full postback, so using the ScriptManager.RegisterAsyncPostBackControl would not work for me. By enclosing the control (which contained a repeater and linkbutton) inside of an UpdatePanel, the linkbutton would cause an asynchronous postback. With no updatepanel, the linkbutton would cause a fullpostback.

Hope this helps someone else.


Inside ItemCreated event of the Repeater control register the button with ScriptManager.

//Inside ItemCreatedEvent
ScriptManager scriptMan = ScriptManager.GetCurrent(this);
LinkButton btn = e.Item.FindControl("order_button") as LinkButton;
if(btn != null)
{
    btn.Click += LinkButton1_Click;
    scriptMan.RegisterAsyncPostBackControl(btn);
}