Search code examples
jqueryasp.net-mvctoast

Rendered source inside browser failed


Using ASP MVC and JQuery, I am trying to show a Toast Notifaction but I got a problem with showing the rendred source inside the browser.

I used this hard coded text as example but I didn't get any notifaction:

    <script src="/template/web/js/jquery-2.2.3.min.js"></script>
@section Scripts {
    <script src="~/scripts/toastr.js"></script>
    <script src="~/scripts/toastr.min.js"></script>
    <link href="~/Content/toastr.min.css" rel="stylesheet" /> 

   <script type="text/javascript">toastr.success("Hello!");</script>
}

Solution

  • It seems that you are using jQuery UI component datepicker, before jQuery and jQuery UI script are being rendered. As the result, it causes the script error, and toastr ends up not working.

    So, you will need to move those jQuery, jQuery UI and toastr scripts inside head tag.