可与http://www.cnblogs.com/oupatch/archive/2005/03/16/119554.html结合使用.
//适应于整站,而不仅是一个贴子.
private void Submit_Click(Object sender,EventArgs e)
{
  //读取Cookie的值(应先检查此Cookie是否存在).
  if(Request.Cookies["UID"]!=null){
    DateTime temp=Convert.ToDateTime(Request.Cookies["UID"].Value);
    if(DateTime.Now<temp.AddMinutes(1)){
      Response.Write("<script>alert('不能连续提交,两次发言间隔为1分钟!!');"+"</"+"script>");
      return;
    }
  }

  HttpCookie cookie=new HttpCookie("UID",DateTime.Now.ToString());
  cookie.Expires=DateTime.Now.AddDays(1);
  Response.Cookies.Add(cookie);

  Response.Write("<script>alert('执行按钮处理!!');"+"</"+"script>");
}

大家如有更好的解决方案,欢迎交流讨论.

posted on 2005-04-12 17:12  oupatch  阅读(1743)  评论(5编辑  收藏  举报