title: How can I get ValidationSummary messages programmatically?
body: <p>I've created an HtmlHelper that helps me show a jQuery modal dialog: I set a message in controller's TempData and if the message is not null, the helper writes an jquery + html code to make popup apears after postback. 
  But I need to show the Validation results as a message (same message displayed by ValidationSummary), and I have no Idea how to accomplish this. Can someone help me? Am I doing it the right way?</p>
  
  <p>My helper.cs: </p>
  
  <pre><code>[...] 
          public static string ModalDialogNotifier(this HtmlHelper helper)
          {
              string message = "";
              if (helper.ViewContext.TempData["message"] != null)
                  message = helper.ViewContext.TempData["message"].ToString();
          if (!String.IsNullOrEmpty(message))
          {
              StringBuilder sb = new StringBuilder();
              sb.AppendLine("&lt;script&gt;$(document).ready(function() {$.blockUI({ message: $('#mdiag')});$('#mdiagok').click(function() {$.unblockUI();return false;});})&lt;/script&gt;");
              sb.AppendFormat("&lt;div id='mdiag'&gt;{0}&lt;input type='button' id='mdiagok' value='Ok' /&gt;&lt;/div&gt;", message);
              return sb.ToString();
          }
          return string.Empty;
      }
  [...]
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code> [HttpPost]
      [Authorize(Roles = "Admin")]
      public ActionResult Create(CreateUserModel Model)
      {
          if (!ModelState.IsValid)
          {
              this.TempData["message"] = "Model is not valid";
          }
          else
          {
             [...]
          }
          return View(Model);
      }
  </code></pre>
  
  <p>My View:   </p>
  
  <pre><code> [...]&lt;%= Html.ModalDialogNotifier()%&gt;[...]
  </code></pre>