问题
I have one of a aspx page in my asp.net project which has a button control after clicking on the button and then refreshing the page using F5 key or refresh button of the browser, instead of setting IsPostBack property to false, it is setting it to true.
Can anyone help me out of this?
回答1:
Clicking the button triggers a HttpPost of the form and it's posted to the same page, which is what's called a post back. Refreshing the page triggers the last executed action, which in this case was a post. Most browsers warn the user about this when they refresh a posted page.
In case you don't want this behaviour you have to make sure that you perform a get operation after the post (the so called "Redirect after post/Get after post"-technique).
One way of achieving it is to end the post back action with:
Response.Redirect(Request.RawUrl);
回答2:
After reading your problem, the page refresh after clicking on asp:button will always send a postback because button's autopostbak control and you can not change it's default behaviour. i can y figure it out by clicking on button you dont want a postback?
and if you wish to partially update the page then make use of <asp:UpdatePanel>
来源:https://stackoverflow.com/questions/5920569/refresh-of-page-set-postback-true