System.Web.HttpContext.Current.Response.Write("<script>window.location=window.location</script>");为什么我使用这段代码解决刷新时候提交数据的问题后 在使用 Response.Write("<script>alert('添加的数据已存在');</script>");就没有办法弹框了
JscriptOperator.Alert(Page, "修改成功!");
public static void Alert(System.Web.UI.Page page, string description)
{
string strScript, strDescription;
string strKey;
int i;
//脚本块的内容
//先将提示信息中的某些字符做转换,否则会影响脚本的执行
strDescription = description.Replace("\"", "\\\"");
strDescription = description.Replace("\\", "\\\\");
strDescription = strDescription.Replace("\r", "\\r");
strDescription = strDescription.Replace("\n", "\\n");
strScript = "<script language=javascript for=window event=onload>\n";
strScript += " window.alert(\"" + strDescription + "\")\n";
strScript += "</script>";
//注册脚本块的Key
strKey = System.DateTime.Now.ToString();
//循环,直至找到某个没被注册过的Key
for (i = 0; i < 10000; i++)
if (!page.ClientScript.IsClientScriptBlockRegistered(strKey + i.ToString()))
break;
page.ClientScript.RegisterClientScriptBlock(page.GetType(), Guid.NewGuid().ToString(), strScript);
}
把两条语句的顺序调换一下