c#弹出提示或者弹出提示并跳转应用
1。提示框有两个选择项,点确定跳转,取消停留在原页面
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "<script>if(confirm('请登录?')){location.href='login.aspx'};</script>", false);
2.提示框只有一个确定按钮,跳转到指定页面
ScriptManager.RegisterStartupScript(page, this.GetType(), "", "<script>alert('请登录?');location.href='login.aspx'</script>", false);
或者是:
<script language="JavaScript">alert('提示信息');-------------------------提示框内容location.href='https://125.69.90.54/';-----------------------点击按钮后跳转页面url
document.onmousedown=click</script>
3、Response.Write
("<script>alert('查询语句执行出错!');window.location.href=DisplayData.aspx</script>");
4、ClientScript.RegisterStartupScript(this.GetType(), "", " <script lanuage=javascript> alert('');location.href='';</script>");
5、System.Web.HttpContext.Current.Response.Write(String.Format("<script language=\"javascript\">alert(\"{0}\");window.location.replace(\"{1}\")</script>", strMessage, strRedirectUrl));
6、Page.ClientScript.RegisterStartupScript(this.GetType(), "d", "alert('请先登录!');location='../login.aspx';", true);
无刷新弹出警告:
ScriptManager.RegisterStartupScript(this.Page, this.GetType(),"onekey", "alert('弹出')", true);
而以下方法,会刷新弹出,比较难看
Response.Write("<script>alert('弹出')</script>");
ClientScript.RegisterStartupScript(this.Page, this.GetType(),"onekey", "alert('弹出')", true);