Translate

What is IsPostBack in ASP.NET?

When user requests first time to an ASP.NET page then the “GET” method of the page is enabled and the “POST” method of the page is disabled. After rendering the ASP.NET page it converts into HTML page and then its “POST” method of the page becomes enabled and the “GET” method of the page becomes disabled.

That's why we get IsPostBack = False at the time of first request to the server and after that we get IsPostBack = True. For example, we bind drop down list by getting data from database under the if(!IsPostBack) condition. If we do not place this condition then the drop down list will be bind every time on post back and we always get the default selected value of the drop down list.

In above example the IsPostBack comes into action and bind the drop down list by taking data from database only if the page is requested first time other wise it will not be bind on post backs.

No comments:

Post a Comment