Refresh of Page set PostBack = true

删除回忆录丶 提交于 2019-12-12 04:22:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!