【问题标题】:Toastr notification not working on asp.net web formsToastr 通知不适用于 asp.net 网络表单
【发布时间】:2020-01-24 15:23:53
【问题描述】:

我正在尝试在我的 ASP.NET Web 表单应用程序中使用 toastr 通知。我写了以下代码:

Toastr.cs

public static class Toastr
    {
        public  static void ShowToastr(this System.Web.UI.Page page, string message, string title, string type)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "toastr_message", String.Format("toastr.{0}('{1}','{2}', { positionClass: 'toast-top-full-width', timeOut: 5e3, closeButton: !0, debug: !1, newestOnTop: !0, progressBar: !0, preventDuplicates: !0, onclick: null, showDuration: '300', hideDuration: '1000', extendedTimeOut:'1000', showEasing: 'swing', hideEasing: 'linear', showMethod: 'fadeIn', hideMethod: 'fadeOut', tapToDismiss: !1 });", type.ToLower(), message, title), addScriptTags: true);
        }
    }

然后点击按钮我正在这样做:

//code for insertion
 cmd.ExecuteNonQuery();

                Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.success('Successfully added URD','Success!')", true);  

在运行时出现错误:

未捕获的引用错误:未定义 toastr 在 test.aspx:407

【问题讨论】:

    标签: asp.net toastr


    【解决方案1】:

    是否在页面中正确声明了 toastr 库?

    jQuery 也声明了吗?

    要测试页面上是否设置了所有内容:打开控制台并输入

    toastr.info("title")
    

    这应该会显示一个简单的通知。如果这不起作用,那么您将开始收到错误消息以帮助您解决问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-06
      相关资源
      最近更新 更多