Search code examples
c#jqueryasp.nettoastr

How can i add close button to toastr.js in asp.net web form?


I'm beginning in asp.net and want to use the toastr.js for show user any message,for that purpose download the toastr.js and in my web form in submit button write this code:

protected void Submit(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(),
    "toastr_message", "toastr.error('There was an error', 'Error')", true);
            Div3.Visible = true;
        }


show me message correctly,but message box not hide,and I want add close button that message box ,when user fire the close button,message start unhide with fade effect.How can I solve that ?thanks.


Solution

  • Adding the closeButton option should do the trick https://github.com/CodeSeven/toastr#close-button:

    Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.error('There was an error', 'Error', { closeButton: true })", true);