Wednesday, February 1, 2012

I wish there was a better way to see if a ViewBag variable existed in ASP.NET MVC 3 and 4 beyond a null check.

@if (ViewBag.ShouldShowSuccessMessage != null)

{

   ViewBag.ShouldShowSuccessMessage = null;

   <script type="text/javascript">

      showSuccess("Your changes have been saved!");

   </script>

}

No comments:

Post a Comment