ASP.NET 解决重复提交问题

1.在ASPX页面下加一个隐藏域         <asp:HiddenField ID="HidSign" runat="server" />

2.cs代码

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                 UpdateSign();
            }
         }




       static string rp_GoodsEdit;
        public void UpdateSign()
        {
            HidSign.Value = DateTime.Now.ToString("ffffff");
            rp_GoodsEdit = HidSign.Value;
        }


//
 protected void btnSave_Click(object sender, EventArgs e)
        {
            if (rp_GoodsEdit == HidSign.Value)
            {
                UpdateSign();
            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "startup", "alert('请勿重复提交!');self.parent.tb_remove('reload');", true);
                UpdateSign();
                return;
            }
 ................
}

  

 

posted @ 2011-12-27 18:36  走路到纽约  阅读(714)  评论(0编辑  收藏  举报