【发布时间】: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
【问题讨论】: