1. 程式人生 > >asp.net中Page.ClientScript.RegisterStartupScript用法小結

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);