按网页上的刷新按纽!ISPOSTBACK里面的代码就会运行一次呀?请问什么原因是?有什么方法让他不访问吗?

解决方案 »

  1.   

    IsPostBack只是判断当前的访问是不是Postback
      

  2.   

    IsPostBack代表是否页面回传,如果是回传的话,就不在向服务器提交已经显示的内容
      

  3.   

    把代码写道
    if (!IsPostBack)
    {
       这里写代码
    }
      

  4.   

    在程序中写:
    protected void Page_Load(object sender, EventArgs e)
        {
              if(!IsPostBack)
               {  }   
        }
    就不会出现你说的那种情况了.
      

  5.   

    这个是.net postback 机制的问题
    你每执行一次post提交
    后 如果没有转向到别的页面 使用IE刷新按钮 就会重新回发刚才的post请求你可以 用一个 值Session["isBack"]或是cookie来判断 是否已经执行了提交
    也可以提交后转向到别的页面或Response.Redirect("你当前的页面", true);
    或者 禁用客户端缓存protected void NoCatchOutPage()
        {
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.Expires = 0;
            HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1); //DateTime.Now.AddDays(-1);
            HttpContext.Current.Response.AddHeader("pragma", "no-cache");
            HttpContext.Current.Response.AddHeader("cache-control", "private");
            HttpContext.Current.Response.CacheControl = "no-cache";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetAllowResponseInBrowserHistory(true);
        }你的PageLoad里面 第一行 调用这个 函数
      

  6.   

    按网页上的刷新按纽!ISPOSTBACK里面的代码就会运行一次呀
    -------------------------------------------------------------
    IE上的刷新,等于重新访问一次页面,!ISPOSTBACK意思是“不是服务器控件postback”,正好满足你的条件,肯定会执行了.把!去掉就行
      

  7.   

    if(!IsPostBack)
               {  }