知识学堂 > 课程 > asp.net先弹出提示再跳转

asp.net先弹出提示再跳转

发布日期:2018/12/23 来源:聚恒【返回】

asp.net后台JS判断先弹出提示再跳转
<a href="javascript:top.location('CareerDetail.aspx?id=<%=item.id %>')" />

1、Response.Write
("<script>alert('查询语句执行出错!');window.location.href=DisplayData.aspx</script>");

2、Page.RegisterStartupScript("msg", "<script>alert('查询语句执行出错!');window.location.href='DisplayData.aspx'</script>");
一般后台弹出提示框,都是用Page.RegisterStartupScript,不用Response.Write的

3、ClientScript.RegisterStartupScript(this.GetType(), "", " <script lanuage=javascript> alert('');location.href='';</script>");   

4、System.Web.HttpContext.Current.Response.Write(String.Format("<script language=\"javascript\">alert(\"{0}\");window.location.replace(\"{1}\")</script>", strMessage, strRedirectUrl));

5、ScriptManager.RegisterStartupScript(this, this.GetType(), "u1", "alert('内容!')", true);

6、Page.ClientScript.RegisterStartupScript(this.GetType(), "d", "alert('请先登录!');location='../login.aspx';", true);

ClientScript.RegisterStartupScript(GetType(), "AlertGo", string.Format("alert('{0}');window.location.href='{1}';", "保存成功!", "NoticeSetting.aspx"), true);

 window.location.replace(urls);页面跳转 不能点击后退

 Page.RegisterStartupScript("a", "<script>alert('提交成功,我们会尽快和您联系!');</script>");

 Page.ClientScript.RegisterStartupScript(this.GetType(), "key", @"<script type='text/javascript'>window.location.href ='Contact.aspx';</script>");  

一样的效果
this.ClientScript.RegisterStartupScript(this.GetType(), "验证码错误", "<script>alert('验证码错误,请重新输入!')</script>");

Page.ClientScript.RegisterStartupScript(this.GetType(), "d", "alert('请先登录!');location='../login.aspx';", true

上一章: CheckBoxList1操作 下一章: Setvariable命令