Alert message in asp.net mvc

2

I have a form in Asp.Net MVC that terminates 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 as soon as the user clicks the 'Save' button pop up or alert with information to him and with the button 'aware' 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 is the simplest way to do this?

    
asked by anonymous 24.06.2014 / 14:49

3 answers

3

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

  

link

<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>
    
24.06.2014 / 17:21
1

I made using 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 : link

    
24.06.2014 / 16:59
0

I already did something like this, in fact I mixed with javascript.

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