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
- @{
- if (TempData["OperationResult"] != null)
- {
- string alertClass = "";
- var operationResult = (EntryOperationOutBase)TempData["OperationResult"];
- if (operationResult.OperationStatus == OperationStatus.Success)
- {
- //I shuold be able to call and show toastr here with below message
- @operationResult.ResultMessageToShow
-
- }
- else
- {
- //I shuold be able to call and show toastr here
- @operationResult.ResultMessageToShow
- }
-
- }
- }
-
-
-
- <script >
- $(document).ready(function () {
- toastr.options = {
- "closeButton": true,
- "debug": false,
- "positionClass": "toast-bottom-right",
- "onclick": null,
- "showDuration": "1000",
- "hideDuration": "1000",
- "timeOut": "5000",
- "extendedTimeOut": "1000",
- "showEasing": "swing",
- "hideEasing": "linear",
- "showMethod": "fadeIn",
- "hideMethod": "fadeOut"
- };
- $('#toastr-success').click(function () {
- toastr.success('This is a success notification from toastr.')
- });
-
- $('#toastr-info').click(function () {
- toastr.info('This is an information notification provided by toastr.')
- });
-
- $('#toastr-warning').click(function () {
- toastr.warning('This is a warning notification provided by toastr.')
- });
-
- $('#toastr-error').click(function () {
- toastr.error('This is an error notification provided by toastr.')
- });
- });
- </script>