0

I would like to show popup message if there is an error on the page but somehow jquery doesn't show anything.

 <script>
     $(document).ready(function () {
         if(@TempData["Error"].ToString() != null)
         {
             alert("Message 1");
         } else {
             alert("Message 2");
         }
    });
 </script>
Hassan
  • 930
  • 3
  • 16
  • 35
AliAzra
  • 889
  • 1
  • 9
  • 28

2 Answers2

0

ToString() is not the correct method name, the correct method name is toString()

Nithya Rajan
  • 4,722
  • 19
  • 30
0

I fixed it with this way

    var val = '@Html.Raw((string)TempData["ErrorMessage"])';
    if(val != "")
    {
        alert(val);
    }
AliAzra
  • 889
  • 1
  • 9
  • 28