Alert message in Asp.net mvc

Asked

Viewed 1,752 times

2

I have in an application in Asp.Net MVC a form that ends as follows

<div class="modal-footer">
    <input class="btn btn-primary" type="submit" value="Salvar" />
    <a class="btn btn-default" onclick="FechaModal();">Cancelar</a>
</div>

I need that as soon as the user click on the 'Save' button a pop up or alert appears with information for him and with the 'aware' button and 'cancel'. The information then of the form will only be sent to the bank after the confirmation of the aware in the pop up and not when the user clicks on the initial save. What’s the simplest way to do that?

  • In this function ai Fechamodal() have you tried to put a pop up and within it the logic ? Or put another recording function in the pop up calling this Fechamodal()... Maybe it works.

3 answers

3

The jQuery UI has the great Dialog who does it for you:

http://jqueryui.com/dialog/#modal-confirmation

<script>
  $(function() {
    $("#dialog").dialog({
      resizable: false,
      height: 140,
      modal: true,
      buttons: {
        "Ciente": {
          click: function() {
            // Coloque aqui sua lógica
            $(this).dialog("close");
          }
        },
        "Cancelar": { 
          class: 'cancel',
          click: function() {
            $(this).dialog("close");
          }
        }
      }
    });
  });
  </script>

1

I did using the confirm()

HTML:

<form action="teste.asp">
    <button id="save" type="submit">Salvar</button>
</form>

JS:

$( document ).ready(function(){
    $('#save').click(function(){
        var a = confirm("Tem certeza que deseja salvar as alterações?");
        if (!a){
        return false;
        }
        e.preventDefault();
    });
});

Link jsFiddle: http://jsfiddle.net/x24bJ/

0

I’ve done something like this, actually I merged with javascript.

<asp:Button ID="Button1" runat="server" OnClientClick="return confirm('Deseja deletar?');" 
    OnClick="Button1_Click">Delete</asp:Button>

Browser other questions tagged

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