I have one Update Query on page_load(). I have a button on page.
I want to execute that query only once, but when I click on button, the page loads again.
I therefore put that button in update panel.
Now when I click on the button, the page doesn’t seem to be reloading but that update query is executing.
what may be the problem?
When using an UpdatePanel it may look like your page doesn’t refresh but actually your whole page life cycle is executed. This is done trough an AJAX request that will only refresh the part within the update panel. You don’t need an UpdatPanel for this situation.
What you need to do is check in your
Page_Loadfunction if the current request is aPostback. A PostBack means that a user action on the page was executed and that an event will be run. If it is, you know that you don’t need to run your query.UpdatePanels may give you a false sense of using AJAX but on the inside they run your whole page life cycle and they are not the same as a real AJAX request.