加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Javascript Alert在重定向到ASP.NET之前

发布时间:2020-12-15 03:58:08 所属栏目:百科 来源:网络整理
导读:我正在使用以下代码在更新面板中更新时显示消息 string jv = "alert('Time OutAlert');";ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"msg",jv,true); 工作正常 但是当我使用重定向后,它加载页面而不显示消息.我希望用户看到消息,点击“确
我正在使用以下代码在更新面板中更新时显示消息
string jv = "alert('Time OutAlert');";
ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"msg",jv,true);

工作正常

但是当我使用重定向后,它加载页面而不显示消息.我希望用户看到消息,点击“确定”后,它应该重定向.

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

解决方法

使用javascript显示警报,然后使用相同的重定向:
ScriptManager.RegisterStartupScript(this,"redirect","alert('Time OutAlert'); window.location='" + 
Request.ApplicationPath + "Nextpage.aspx';",true);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读