title: How to show alert message from MVC?
body: <p>I am trying to show alert message in MVC view but it is not showing. Here is what I have tried so far:</p>
  
  <p>In controlller page:</p>
  
  <pre><code>if(dataFound)
  {
    ViewBag.SuccessMessage = "The search results has been sent.";
  }
  </code></pre>
  
  <p>In view page:</p>
  
  <pre><code>@if (ViewBag.SuccessMessage != null)
  {
      &lt;script&gt;
          $(document).ready(function () {
              alert('@ViewBag.SuccessMessage');
          });
      &lt;/script&gt;
  }
  </code></pre>
  
  <p>But still not showing any alert on the view page. And I have found by debugging that in the view page it is coming inside the if condition and to the script but still not showing any message. Please advise on this. Thanks.</p>