If inside the button

Asked

Viewed 153 times

2

I have this "Receive" button, and this checkbox that when it is marked, means that the account is paid: inserir a descrição da imagem aqui

I need that when he clicks the Receive button, and the checkbox is already checked, that he tells you that the account has already been received, and not redirect the page, This is the Receive button code:

  <a asp-page="Recebimento" asp-route-id="@item.Id" class="btn btn-sm btn-warning">Receber</a>

How can I make an if inside the button ?

  • It does not recognize this command on the button

1 answer

2


The most correct is to make the logic to create two different buttons:

@if(Model.Quitado){
  <a onclick="alert('Conta já recebida')" class="btn btn-sm btn-warning" disabled>Receber</a>
} else {
  <a asp-page="Recebimento" asp-route-id="@item.Id" class="btn btn-sm btn-warning">Receber</a>
}

Replace the button logic which is best for your application.

  • It worked fine, thank you.

Browser other questions tagged

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