Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在asp.net中使用“Mesi”Jquery插件_Javascript_Asp.net_Jquery Plugins_Messagebox - Fatal编程技术网

Javascript 在asp.net中使用“Mesi”Jquery插件

Javascript 在asp.net中使用“Mesi”Jquery插件,javascript,asp.net,jquery-plugins,messagebox,Javascript,Asp.net,Jquery Plugins,Messagebox,我正在Login.aspx中使用“Mesi”Jquery通知插件,如果用户未注册,则会向用户显示一条消息,并将其重定向到Register.aspx: ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), " <script>alert('this is a message');window.location.href='Register.aspx';</s

我正在Login.aspx中使用“Mesi”Jquery通知插件,如果用户未注册,则会向用户显示一条消息,并将其重定向到Register.aspx:

 ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "    <script>alert('this is a message');window.location.href='Register.aspx';</script>", true);
这段代码运行良好,我应该单击OK按钮,然后页面将被重定向,但当我使用Mesi.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);

您是否使用了如图所示的代码?你的ASP.NET代码中不应该有重定向代码window.location.href='Register.aspx',请你再解释一下好吗?我需要专家的指导如果你把上面的代码按原样放到JavaScript中,下面的代码按原样放到你的C代码中,替换旧的代码行,应该可以工作。该函数不会立即重定向,但只有在警报关闭时才重定向-通过调用回调函数,我复制并粘贴了上面的代码片段,并尝试了重定向,但重定向仍不像我们预期的那样。我的错误。我没有意识到-回调需要显式按钮才能工作。我已更新JavaScript代码-请重试