Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di mexican
    Registrato dal
    Oct 2001
    residenza
    cava de tirreni
    Messaggi
    3,541

    ImageButton dentro repeater e ajax

    Ciao a tutti,
    io devo fare un repeater con delle imagebutton e al click mi deve far partire un comando ajax.
    Ecco il codice che ho:

    Lato aspx
    codice:
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        	    <ContentTemplate>
        	    
        	        <asp:Repeater ID="lstphoto" runat="server" Visible="true">
                        <itemtemplate>
                            <div class="box140 h110 floatleft backwhite borderGrey margine5">
                                <asp:ImageButton ID="Btncerca" runat="server" OnClick="Btncerca_Click"/>
                            </div>
                        </itemtemplate>
                    </asp:Repeater>
                    
                    <asp:Repeater ID="lstgallery" runat="server" Visible="false">
                        <itemtemplate>
                            <div class="box140 h110 floatleft backwhite borderGrey margine5">
                                " title="<%#Eval("titolo")%>">[img]public/Foto/Small/<%#Eval([/img]" alt="<%#Eval("titolo")%>" class="padd10" border="0" />
                            </div>
                        </itemtemplate>
                    </asp:Repeater>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Btncerca" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>

    Lato vb
    codice:
    Protected Sub lstphoto_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles lstphoto.ItemDataBound
    
            If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
    
                Dim btnImg As ImageButton = DirectCast(e.Item.FindControl("ImageButton1"), ImageButton)
    
                Dim strImgName As String = DataBinder.Eval(e.Item.DataItem, "foto").ToString()
    
                btnImg.CommandArgument = DataBinder.Eval(e.Item.DataItem, "idcategoria").ToString()
    
    
                btnImg.ImageUrl = "~/Public/Foto/small/" & strImgName
            End If
    
        End Sub
    Lato vb ho messo solo l'itemdatabound poi la creazione della lista penso sia inutile.

    Il problema è che mi da questo errore:

    Dettagli eccezione: System.InvalidOperationException: Impossibile trovare un controllo con ID 'Btncerca' per il trigger nell'UpdatePanel'UpdatePanel1'.

    Cosa sbaglio?

    Grazie a tutti

  2. #2
    puoi togliere tranquillamente il trigger.

    Di default, un updatePanel ha la proprietà ChildrenAsTriggers=true, ovvero qualsiasi controllo al suo interno che effettua un postBack, viene considerato come un trigger asincrono.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.