开发者

Update panel and AsyncPostbackTriggers

I would love to add AsyncPostback Triggers dynamically to the ImageButtons found within the UpdatePanel con开发者_Go百科trol

<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
 <Triggers></Triggers>
    <ContentTemplate>
            <asp:ListView ID="ListView2" runat="server">
                <ItemTemplate>
                    <asp:ImageButton ID="btnRemove" runat="server" ImageUrl="~/Images/Delete.png" CommandName='<%# DataBinder.Eval(Container.DataItem, "QuestionsID") %>'/>
                </ItemTemplate>
           </asp:ListView>
 </ContentTemplate>
 </asp:UpdatePanel>
</asp:Content>

The problem is that i cannot figure out how to do it!

I already tried different ways, but NONE seems to work.

My last try, was trying to add the triggers in the ListView ItemDataBound event

Private Sub ListView2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ListView2.ItemDataBound         
        For Each btnError As ImageButton In e.Item.Controls.OfType(Of ImageButton)()
            Select Case btnError.ID
                Case "btnRemove"
                    Dim trigger As New AsyncPostBackTrigger()
                    trigger.ControlID = UpdatePanel1.FindControl(btnError.ID).UniqueID
                    UpdatePanel1.Triggers.Add(trigger)
            End Select
        Next
    End Sub

which of course is not correct.

So could you please tell me how can i add dynamically triggers to the UpdatePanel controls?


Since your buttons are already inside the update panel there is no reason for adding them dynamically as they generate an async postback anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜