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) Handles MyBase.Load
  If (Not IsPostBack) Then
    DataGrid1.DataSource = New Contact()
    DataGrid1.DataBind()
  End If
End Sub

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.20.68