Home > Articles > Programming > ASP .NET

  • Print
  • + Share This
From the author of

Once the user interface of the web form was built, it was time to add functionality to the application. This application displays a message when one of the menu items is clicked, and displays a greeting, using a name entered in the TextBox control, when the button is clicked. You can add event handlers by selecting the Event tab on the Object Inspector and double-clicking one of the events in the list. However, this application uses default event handlers, so there's an easier way. Double-clicking the button automatically creates a callback method for the Button control's Click event, as shown in Listing 1.

Listing 1 Button Click Event Callback Generated by C#Builder

private void btnSayHello_Click(object sender, System.EventArgs e)
    this.lblInfo.Text = "Hello " + this.txtName.Text;

The code in Listing 1 shows the callback method in the code-behind file generated by C#Builder when the Button control was double-clicked on the Designer Surface. Since I had previously modified the ID property of the Button control in the Object Inspector, the method was generated with a name that's more meaningful than the default button1.


The same process used to code a callback for the Button control can be used with the LinkButton controls.

  • + Share This
  • 🔖 Save To Your Account