Sheikh parvaz

Sheikh parvaz

  • NA
  • 199
  • 105.7k

Using Toastr notification in mvc

Apr 4 2017 3:42 AM
Hi, 
I have a situation where I want to display toastr notification on successfull completetion of operation without clicking and showing.on button click it is working but i need on operation .  My code is
  1. @{  
  2.     if (TempData["OperationResult"] != null)  
  3.     {  
  4.         string alertClass = "";  
  5.         var operationResult = (EntryOperationOutBase)TempData["OperationResult"];  
  6.         if (operationResult.OperationStatus == OperationStatus.Success)  
  7.         {  
  8.             //I shuold be able to call and show toastr here with below message
  9.           @operationResult.ResultMessageToShow  
  10.              
  11.         }  
  12.         else  
  13.         {  
  14.             //I shuold be able to call and show toastr here
  15.           @operationResult.ResultMessageToShow
  16.         }  
  17.         
  18.     }  
  19. }  
  20.   
  21.   
  22. // Toastr is   
  23.  <script >  
  24.     $(document).ready(function () {  
  25.         toastr.options = {  
  26.             "closeButton"true,  
  27.             "debug"false,  
  28.             "positionClass""toast-bottom-right",  
  29.             "onclick"null,  
  30.             "showDuration""1000",  
  31.             "hideDuration""1000",  
  32.             "timeOut""5000",  
  33.             "extendedTimeOut""1000",  
  34.             "showEasing""swing",  
  35.             "hideEasing""linear",  
  36.             "showMethod""fadeIn",  
  37.             "hideMethod""fadeOut"  
  38.         };  
  39.         $('#toastr-success').click(function () {  
  40.             toastr.success('This is a success notification from toastr.')  
  41.         });  
  42.   
  43.         $('#toastr-info').click(function () {  
  44.             toastr.info('This is an information notification provided by toastr.')  
  45.         });  
  46.   
  47.         $('#toastr-warning').click(function () {  
  48.             toastr.warning('This is a warning notification provided by toastr.')  
  49.         });  
  50.   
  51.         $('#toastr-error').click(function () {  
  52.             toastr.error('This is an error notification provided by toastr.')  
  53.         });  
  54.     });  
  55. </script>  
 

Answers (3)