asp.net中Page.ClientScript.RegisterStartupScript用法小结(转)

//ASP.NET后台页面跳转 

Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>if(confirm('保存成功!是否继续添加?')){location.href='ProductonAdd.aspx'}else{location.href='ProductonList.aspx'}</script>");

//后台弹出确定框

ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('请正确输入!');</script>");

//ASP.NET后台页面跳转

Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('数据添加成功!');{location.href='ProductonList.aspx'}</script>");

Page.ClientScript.RegisterStartupScript(typeof(string), "", "<script>window.location.href='AdminMain.aspx';</script>");

//后台弹出文本框
ScriptManager.RegisterStartupScript(Page, typeof(string), "popUp", "window.open('rptView.aspx','打印预览','toolbar=no,location=no,scrollbars=yes,top=200px,left=200px,width=904px,height=650px')", true);

原文地址:https://www.cnblogs.com/xiaolei1314/p/3799285.html