Click here to Skip to main content
15,886,799 members
Articles / Web Development / ASP.NET
Tip/Trick

Prevent firing button click event when refreshing the page

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
10 Oct 2011CPOL 23.2K   2   2
Prevent firing button click event when refreshing the page
During development we can come across this issue. I found many solutions about this issue. However i found an easy solution for this.

I add the following line of code in my button click event and it resolves the problem.

C#
Page.Response.Redirect(Page.Request.Url.AbsoluteUri);


It prevents firing the button click event when we refresh the page.

License

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


Written By
Team Leader
India India
Sandesh has a 11 years of total professional experience in a software development. He first handled the computer in his school days when he was in 7th std working on Lotus. In summer vacation, the school authorities allowed him and other students to use the computers for practicing Lotus and playing different games Smile | :) .

He has done computer engineering. Currently he is working in Net 4.0 framework. Even though he is using .Net 4.0 framework for development but still he has not got a chance to work with newer technologies like MVC, WCF etc. However he always try to learn these technologies from his end and eagerly waiting for a chance to work with the newer technologies like MVC, WCF and Silverlight etc.

Comments and Discussions

 
QuestionThank you Pin
Dilan Fdo26-May-14 23:06
Dilan Fdo26-May-14 23:06 
AnswerRe: Thank you Pin
Sandesh M Patil27-May-14 23:22
Sandesh M Patil27-May-14 23:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.