Show Info, Success, Error and Warning message using jQuery toastr plugin

Last Reply one year ago By dharmendr

Posted one year ago

How to show toastr msg on client side in c#

protected void Page_Load(object sender, EventArgs e)
    {
 ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>showpop('" + "desc" + "','" + "title" + "')</script>", false);

}

 

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.js"></script>

<link rel="stylesheet" type="text/css" href="../components/revolution_slider/css/style.css" media="screen" />

<script type="text/javascript">
       
       function showpop(msg, title) {
           debugger;
           // alert("ok");
           toastr.options = {
               "closeButton": false,
               "debug": false,
               "newestOnTop": false,
               "progressBar": true,
               "positionClass": "toast-top-left",
               "preventDuplicates": true,
               "onclick": null,
               "showDuration": "300",
               "hideDuration": "1000",
               "timeOut": "120000",
               "extendedTimeOut": "1000",
               "showEasing": "swing",
               "hideEasing": "linear",
               "showMethod": "fadeIn",
               "hideMethod": "fadeOut"
           }
          // toastr['success'](msg, title);
           var d = Date();
            
           toastr.success(msg, title);
            return false;
       }
    </script>

 

You are viewing reply posted by: dharmendr one year ago.
Posted one year ago

Hi mukesh1,

Its working. Check this example. Now please take its reference and correct your code.

Javascript

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.js"></script>
<link media="screen" rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.css" />
<script type="text/javascript">
    function showpop(msg, title) {
        toastr.options = {
            "closeButton": false,
            "debug": false,
            "newestOnTop": false,
            "progressBar": true,
            "positionClass": "toast-top-left",
            "preventDuplicates": true,
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "120000",
            "extendedTimeOut": "1000",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        }
        toastr.success(msg, title);
        toastr.warning(msg, title);
        toastr.info(msg, title);
        toastr.error(msg, title);
        return false;
    }
</script>

C#

protected void Page_Load(object sender, EventArgs e)
{
    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "showpop('" + "Description" + "','" + "Title" + "')", true);
}

Screenshot