Button is triggered even disabled, what to do?

2

I have a linkButton that is disabled via server, like this:

lkExcluir.Enabled = false;

Code:

 <asp:LinkButton ID="lkExcluir" runat="server" Text="[Excluir]" Font-Bold="true" OnClick="lkExcluir_Click" OnClientClick="return confirm('Tem certeza que deseja excluir');"></asp:LinkButton>

If I click the unchecked button, the message Are you sure you want to delete if ok is displayed, the lkExcluir_Click event is displayed, what should I do to not display the message and therefore does not trigger the event?

    
asked by anonymous 25.11.2014 / 13:04

1 answer

5

You need to disable the OnClientClick also in the same place where you put Enabled = false.

if (lkExcluir.OnClientClick != null)
{
    lkExcluir.OnClientClick = null;
}
    
25.11.2014 / 13:13