日期:2014-05-19  浏览次数:20453 次

问关于history.go(-2)的问题
在网上查到可以用
Response.Write( " <script   language=javascript> history.go(-2); </script> ");
实现返回上一页面,加入到“确定”以及“取消”按钮的onclick事件中使用也很方便,但遇到了个问题:
我的“确定”按钮是要判断某一TextBox是否非空并提示的,在我提示过一次以后,再点“确定”按钮history.go(-2)返回的就成了我提示之前的页面,也就是当前页面而不是上一页面了,请问这该如何写?

------解决方案--------------------
ViewState中放一个值,每次Page_Load就-1.
------解决方案--------------------
放在viewstate中可以
if (ViewState[ "count "] != null)
{
int count = (int)ViewState[ "count "];
ViewState[ "count "] = count - 1;

}
else
{
ViewState[ "count "] = -1;
}