.NET 解决重复提交问题

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

2.cs代码

protectedvoidPage_Load(objectsender, EventArgs e)
        {
            if(!IsPostBack)
            {
                 UpdateSign();
            }
         }
 
 
 
 
       staticstringrp_GoodsEdit;
        publicvoidUpdateSign()
        {
            HidSign.Value = DateTime.Now.ToString("ffffff");
            rp_GoodsEdit = HidSign.Value;
        }
 
 
//
protectedvoidbtnSave_Click(objectsender, 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 on 2013-05-09 17:26  Lucy Yang  阅读(264)  评论(0编辑  收藏  举报

导航