In my ASP.Net Web Site I have a button.When I click the button and then reload the page via browser,the click event of the button fires.Where is a problem,please help me.
One way to prevent this from happening is to use Response. Redirect("same_page") to the same page after the event logic. This will force the page to reload and thereafter doing any further page refreshes would not call the button click event.
reload() method gives the same result as pressing the reload button on your browser. This method reloads the page from directly the browser's cache by default. If the forceGet property is set to true, the web page will be reloaded from the server.
For example, if you are on a web page, refreshing the page displays the most recent content published on that page. Essentially, you're asking the site to send your computer the newest version of the page you're viewing. 2. The refresh button, also known as the refresh option, is a function of all Internet browsers.
Set AutoPostback = false for insert button, and this will do the trick for you.
If I understand correctly.
You have a web form with a button.
You push the button which causes a post back and the event handler for the button press to execute.
Then you hit refresh and the page has the button event handler execute again.
The reason for this is your refreshing the last information sent to the server. Which is the button click information in the __doPostback. This is why you are seeing the event of the button fire again.
Here is an article talking about how to detect a refresh over a postback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With