I have written some codes in !IsPostBack
block. This code is getting executed when the page loads for the first time. That is fine. But the problem is, when I refresh the page by hitting the f5 key this executes again which I don't want to do. I have searched many articles and found difference between PostBack
and refresh. I know about this. But my question is difference between !IsPostBack
and Refresh. Can we write some code which executes only when the page loads for the 1st time not when we refresh the page. By the way I have written my !IsPostBack
block inside Page_Init()
method and I am using c# for codebehind. Thanks.
Refersh and IsPostback are somewhat unrelated:
Combining that you can get Refresh that triggers either branch of if (IsPostBack)
check. In most cases so server will receive GET request and hence execute !IsPostBack
branch.
If you really need to detect if page was rendered once already - setting cookie or writing information into Session
would be reasonable solution.
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