Button is triggered even disabled, what to do?

Asked

Viewed 187 times

2

I have a linkButton that is disabled via server, so:

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 on the button Untied, the message appears Are you sure you want to delete case okay the event is arranged lkExcluir_Click, what should I do to not display the message and consequently does not trigger the event?

1 answer

5


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

if (lkExcluir.OnClientClick != null)
{
    lkExcluir.OnClientClick = null;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.