Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a save button for saving data.After saving data i redirect from that page to another page.The problem is before redirect if i click twice on that button the data gets saved twice.I want to prevent this from happening.once clicked until redirect the user should not be able to click on that button until redirecting to another form.How to do this?Any ideas?
Posted

C#
document.getElementById("buttonID").onclick = function() {
    this.disabled = true;
}
 
Share this answer
 
Comments
Tom Marvolo Riddle 19-Feb-14 4:22am    
my 5!
okay so you have a save button...

lets call the button button2 & it will execute Save.all();
C#
bool CanSave = true

     private void button2_Click(object sender, EventArgs e)
       {

          if(CanSave == true)
             {
                Save.all();
                CanSave = false ;
                  }
                  else 
                {

                   MessageBox.Show("You cant multi save Please wait...");

                }
             }


       }                                                                          
 
Share this answer
 
v3
In addition to disabling the button, may be display some message to let the user knows that his request is being processed, that will assure him so he will not try to click again. Check this out: Submit Once with an ASP.NET Button Server Control[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900