what's the difference between these two actually ? Requesting page for the first time (or hitting enter in address bar) gives Ispostback = fasle but when i refresh my page then it sets isPostback = true, why ? it should not do like this for refreshing ?

The first time you access the page, asp.net knows that it was not a postback that occurred from the same page.

Since you only have one form element on the page, any time you click on a submit button or another control set to autopost back, the same page will be reloaded. You can check to see if the page was a post back using IsPostBack.

Sometimes you only want to do specfic things the first time the page is loaded, not on post back, say connect to a DB to populate data on the page, so you would check by !IsPostBack (is not postback). Or say filling a dropdown list's items. you only want to do that on a non post back.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.