asp.net页面弹出对话框
一、Response.Write的方式
Response.Write("<script language='javascript'>window.dialogArguments.loginInfo.location.reload();window.close(this);</script>");
但会影响页面的样式控制;
二、Page.RegisterStartupScript方法
Page.RegisterStartupScript("", "<script language=javascript>alert('你的没有登录!请登录!!');window.showModalDialog('LoginForm.aspx',parent,'dialogWidth:400px;dialogHeight:300px;center:yes;status:no;scroll:yes;help:no;');</script>");
Page.RegisterStartupScript("message", "<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
/// 显示消息提示对话框,并进行页面跳转
/// </summary>
/// <param name="page">当前页面指针,一般为this</param>
/// <param name="msg">提示信息</param>
/// <param name="url">跳转的目标URL</param>
public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url)
{
StringBuilder Builder = new StringBuilder();
Builder.Append("<script language='javascript' defer>");
Builder.AppendFormat("alert('{0}');", msg);
Builder.AppendFormat("top.location.href='{0}'", url);
Builder.Append("</script>");
Page.RegisterStartupScript("message", Builder.ToString());
}
Page.RegisterStartupScript("","<script>if(confirm('注册成功,请登陆!')){window.open('index.aspx','_self');}</script>");
RegisterClientScriptBlock("","<script>alert('所要弹出的提示信息');</script>");