0
I’m having trouble with a Repeater on the webform, where the Onitemcommand event is not working. It should be triggered when I click on the linkbutton.
Code aspx:
<asp:Repeater ID="repeaterImagens" runat="server"
OnItemCommand="repeaterImagens_ItemCommand"
OnItemDataBound="repeaterImagens_ItemDataBound">
<ItemTemplate>
...
<asp:LinkButton ID="lbExcluir" runat="server"
CommandName="excluir"
CommandArgument="<%# ((String)Container.DataItem) %>"
OnClientClick="if (!confirm('Confirma a exclusão desta imagem?'));">
</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
Code Behind C#
protected void repeaterImagens_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("excluir"))
{
ExcluirArquivo(e.CommandArgument.ToString());
}
}
I tested in debug mode, when clicking on Linkbutto nothing happens, not even calls the Itemcommand event.
Hello @user5482, maybe the error on is in Onclientclick, I think you should put a returna explicitly, something like this: Onclientclick="Return window.confirm('Confirms the deletion of this image?');">
– user2177