JavaScript警告之前重定向在ASP.NET [英] Javascript Alert before redirecting in ASP.NET

查看:111
本文介绍了JavaScript警告之前重定向在ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的code来显示信息,而在更新面板更新

 字符串JV =警报('时间OutAlert');;
ScriptManager.RegisterClientScriptBlock(这一点,this.GetType(),味精,合资公司,真正的);
 

它工作正常。

但是当我后,使用重定向它加载的页面不显示的消息。我希望用户看到的消息,并点击确定就应该重定向后。

 字符串JV =警报('时间OutAlert');;
ScriptManager.RegisterClientScriptBlock(这一点,this.GetType(),味精,合资公司,真正的);
的Response.Redirect(〜/ Nextpage.aspx);
 

解决方案

显示的javascript警报,然后做重定向使用相同的:

  ScriptManager.RegisterStartupScript(这一点,this.GetType(),重定向,
警报('时间OutAlert');了window.location ='+
Request.ApplicationPath +Nextpage.aspx';,真);
 

I am using following code to display message while updating in update panel

string jv = "alert('Time OutAlert');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", jv, true);

It works fine.

But when I use Redirect after it it loads the page without displaying the message. I want user to see the message and after clicking on "ok" it should redirect.

string jv = "alert('Time OutAlert');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", jv, true);
Response.Redirect("~/Nextpage.aspx");

解决方案

Display the alert with javascript and then do the redirect with the same:

ScriptManager.RegisterStartupScript(this,this.GetType(),"redirect",
"alert('Time OutAlert'); window.location='" + 
Request.ApplicationPath + "Nextpage.aspx';",true);

这篇关于JavaScript警告之前重定向在ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆