我在 Login.aspx 中使用“messi”Jquery 通知插件,如果用户未注册,则会向用户显示一条消息并将其重定向到 Register.aspx:
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), " <script>alert('this is a message');window.location.href='Register.aspx';</script>", true);
这段代码工作正常,我应该单击“确定”按钮,然后页面将被重定向,但是当我使用 Messi.alert()
而不是 alert()
时,消息仅出现一秒钟,然后重定向会自动完成。
我需要使用这个插件我该怎么办?
最佳答案
在这种情况下你必须使用回调。例如。在 JavaScript 代码中将函数定义为:
function alertRedirect(message, url) {
new Messi(message, {title: 'Warning',
modal: true,
buttons: [{id: 0, label: 'OK', val: 'OK'}],
callback: function() {
location.href = url;
}});
}
并在您的 .net 代码中调用它:
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alertRedirect('this is a message','Register.aspx');", true);
关于javascript - 在asp.net中使用 'messi' Jquery插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21145419/