Dynamically added ASynch Triggers only fire once?

Last post 01-12-2009 1:48 PM by Schmakt. 2 replies.

Sort Posts:

  • Dynamically added ASynch Triggers only fire once?

    01-08-2009, 7:59 PM
    • Member
      148 point Member
    • Schmakt
    • Member since 12-06-2007, 3:24 PM
    • Charlotte, NC
    • Posts 136

    I have a Repeater control whose ItemTemplate contains an ImageButton control.

                    <asp:Repeater ID="rptQuestions" runat="server" OnItemDataBound="rptQuestions_DataBind">
                        <ItemTemplate>
                            <asp:Label ID="lblMonthName" runat="server" Font-Bold="true"><%# Eval("MonthName") %></asp:Label><br />
                            <center>
                                <asp:ImageButton ID="ibLogos" runat="server" CommandArgument='<%# Eval("MonthID") %>' OnClick="ibLogos_Click" ImageUrl='<%# Eval("ImageURL") %>' />
                            </center>
                            <hr />
                        </ItemTemplate>
                    </asp:Repeater>

     

    On the same page, I have an UpdatePanel whose content I would like to change based on the ImageButton within the Repeater that is clicked, but I don't want to have the Repeater inside the update panel.  So I've attempted to add the ImageButtons from the Repeater as AsynchPostBackTriggers for the UpdatePanel in the "rptQuestions_DataBind" event:

         protected void rptQuestions_DataBind(object sender, RepeaterItemEventArgs e)
        {
            ImageButton ibLogos = (ImageButton)e.Item.FindControl("ibLogos");
            if (ibLogos != null)
            {
                AsyncPostBackTrigger trig = new AsyncPostBackTrigger();
                trig.ControlID = ibLogos.UniqueID.ToString();
                trig.EventName = "Click";
                upContest.Triggers.Add(trig);
            }
        }

     

    The page loads fine and the first time I click one of the ImageButtons in the Repeater, the UpdatePanel reloads without refreshing the page.  If I click another ImageButton, the entire page reloads and will reload every time after the first ImageButton has been clicked.  Any idea what I'm doing wrong?  Thanks!

  • Re: Dynamically added ASynch Triggers only fire once?

    01-12-2009, 3:00 AM
    Answer

    Hi,

    You can set RowCommand to handle imageButton click. And set RowCommand event of Repeater control as the trigger of UpdatePanel, rather than set each button as the trigger.


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Dynamically added ASynch Triggers only fire once?

    01-12-2009, 1:48 PM
    • Member
      148 point Member
    • Schmakt
    • Member since 12-06-2007, 3:24 PM
    • Charlotte, NC
    • Posts 136

     thanks for the feedback... I had to switch the control from a Repeater to a GridView to use RowCommand... that required a lot of messing with the DataBound events on the GridView Items to get the look back to the way I wanted it, but it did solve the UpdatePanel issue.  Thank you :)

Page 1 of 1 (3 items)
Microsoft Communities