1、Page_Load中加入
Response.Cache.SetNoStore();
//Session中存储的变量“IsSubmit”是标记是否提交成功的
if (!IsPostBack)
if (Session["IsSubmit"]==null)
Session.Add("IsSubmit",false);
if ((bool)Session["IsSubmit"])
{
//如果表单数据提交成功,就设“Session["IsSubmit"]”为false
Session["IsSubmit"] = false;
//显示提交成功信息
TextBox1.Text = " * 提交成功!";
//Response.Write("<script>document.write('<div style="position:relative; left:10px; top:10px; width:90%; height=+30px;" id=DivRule><font style="font-size: 14pt; font-family: 宋体, MS Song; color: #4E4E4E; line-height: 14pt" >警告: 网页已经过期</font></div>" +
//"<div id=Out0 style="position:relative; left:20px; top:+15px; width:90%;" >您申请的网页是用表单中提交的信息创建的。该网页已失效。由于有安全预警功能,Internet Explorer 不会自动再次提交您的信息。<BR><BR>要重新提交信息并查看该网页,请单击<b>刷新</b>按钮或单击<b><a href="/index.html">返回首页</a></b>。</div>');</script>");
//Response.End();
}
else
{//否则的话(没有提交,或者是页面刷新),不显示任何信息
TextBox1.Text = "";
Response.End();
}
2、提交按钮中加入
Session["IsSubmit"] = true;
Response.Redirect ("本页");