Managing Round-Trips to the Server

A Web page defines an IsPostBack property. You can poll the IsPostBack property to determine whether the page is being rendered as the result of a request or a user postback. For example, when we click the paging links for a DataGrid control, we are posting the page back, but the event handler is binding the DataGrid control. Hence we don't need to bind the DataGrid control in the Page_Load event a second time. You can use the IsPostBack property to eliminate the extra call to DataBind. Listing 16.14 demonstrates a Page_Load event that checks the IsPostBack property.

Listing 16.14. Using IsPostBack to Eliminate Extra Calls to DataBind
 Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) ...

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.