Search code examples
asp.net-mvcmessageboxreplace

What can I use to replace MessageBox.Show in MVC?


I am developing a MVC intranet.

I'm more used to developing for windows, but I've been assigned this project.

I always used MessageBox.Show to display messages about exceptions.

What can I use to do it in MVC?


Solution

  • Use jquery dialog:

    <div id="msgDialog" title="Warning">Please select an item.</div>
    
    <script type="text/javascript">
    
    $(document).ready(function () {
      // set up message dialog
      $("#msgDialog").dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        buttons: {
          " OK ": function () { $(this).dialog("close"); }
        }
      });
    
    });
    
    // to invoke:
        $("#msgDialog").dialog('open');
    </script>