如果用户未使用jquery插件进行身份验证,我想显示一条通知,但我不知道如何执行此操作。一直说该函数未定义。我必须将脚本加载到到目前为止我已经尝试过的masterpa.ge的底部。此代码也位于masterpage.cs
上protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.User.Identity.IsAuthenticated)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowNoty", "ShowNoty('error','Accesso não autorizado.');", true);
FormsAuthentication.RedirectToLoginPage();
}
else
{
}
}
Js功能
$(window).on('load', function () {
$(document).ready(function ShowNoty(type, message) {
var noty = new Noty({
theme: 'bootstrap-v4',
text: message,
type: type,
timeout: 3000,
animation: {
open: 'animated bounceInRight', // Animate.css class names
close: 'animated bounceOutRight' // Animate.css class names
},
layout: 'topRight',
onHover: function () {
noty.Close();
},
}).show();
});
});