Handling data postback

As mentioned earlier, a WebForm is posted back to the server only when a Button, LinkButton, or ImageButton control is clicked. After the form is posted to the server, it is processed at the server. You can handle data postback corresponding to the click of a button in one of the following ways:

• Write an event handler for the Click event of the button.

• Write the event handler for the Load event of the WebForm. The Load event is generated when the form is loaded. You can use the IsPostBack property in the Load event to determine whether the page has been processed for the first time or by a button click. The following code depicts the event handler for a WebForm's Load event:

• protected void Page Load(object sender, EventArgs e)

• //Evals true first time browser hits the page

0 0

Post a comment