0
Hello, I am new here and I am in need of a help. I already searched the net and the solutions I found do not work. I have an image gallery editing screen, made with a Repeater, in each image listed I have a button that opens a modalpopup Ajax with a Fileupload. This way I can replace the selected photo. The problem is that I can’t upload the photo. I just can’t find the Fileupload file on the button click on the Behind code. Can anyone help me? I’ve tried everything and I don’t know what I’m doing wrong. html:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div class="card">
<img src='<%# "../fotosanuncios/" + Eval("idAnuncio") + "/" + Eval("NomeFotoMini") %>'/>
<div class="containerCard">
<asp:LinkButton ID="LBSubstituir" runat="server" ToolTip="Substituir Foto"><i class="fa fa-pencil-square-o fa-lg" aria-hidden="true"></i></asp:LinkButton>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderSub" runat="server" BackgroundCssClass="modalBackground" TargetControlID="LBSubstituir" PopupControlID="PanelSubstituir" CancelControlID="BtCancelar" DropShadow="True"></ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="PanelSubstituir" runat="server" CssClass="modalPopup" style="width:400px;">
<asp:FileUpload ID="FileUpload2" runat="server" CssClass="cg-inputform" /><br />
<asp:Button ID="BtCancelar" Text="Cancelar" runat="server" CssClass="cg-inputGrey" />
<asp:Button ID="BtSalvar" Text="Salvar" runat="server" OnClick="BtSalvar_Click" CommandArgument='<%# Eval("idFoto") + "," + Eval("nomeFoto") + "," + Eval("nomeFotoMini") %>' CssClass="cg-inputGreen" />
</asp:Panel>
<asp:LinkButton ID="LinkButtonRight" runat="server" OnClick="LinkButtonRight_Click" CommandArgument='<%# Eval("idFoto") + "," + Eval("nomeFoto") + "," + Eval("nomeFotoMini") %>' ToolTip="Girar a Direita"><i class="fa fa-repeat" aria-hidden="true"></i></asp:LinkButton>
<asp:LinkButton ID="LinkButtonLeft" runat="server" OnClick="LinkButtonLeft_Click" CommandArgument='<%# Eval("idFoto") + "," + Eval("nomeFoto") + "," + Eval("nomeFotoMini") %>' ToolTip="Girar a esquerda"><i class="fa fa-undo" aria-hidden="true"></i></asp:LinkButton>
</div>
</div>
</ItemTemplate>
my codebehind
protected void BtSalvar_Click(object sender, EventArgs e)
{
int idAnuncio = Convert.ToInt32(this.Request.QueryString["idAnuncio"]);
Button BtSalvar = sender as Button;
string[] commandArgs = BtSalvar.CommandArgument.ToString().Split(new char[] { ',' });
string idFoto = commandArgs[0];
string NomeFoto = commandArgs[1];
string NomeFotoMini = commandArgs[2];
RepeaterI
tem di = BtSalvar.NamingContainer as RepeaterItem;
FileUpload fUpload = di.FindControl("FileUpload2") as FileUpload;
if (fUpload.HasFile)
{
//salva a foto
}
}
Sorry I never worked with updatepanel, should I insert all the Repeater into the updatepanel? And because this way it takes the values of fileupload? Thanks!!
– CriGru
Repeateritem di = Btsave.Namingcontainer as Repeateritem;
– CriGru