Programming the Button


Now you ll write some code that takes the text that the user enters into the text box and displays it as the text of the label. This program isn t very sophisticated, but you ll learn a surprising amount about Web programming from just this simple example.

Program the Button control

  1. In Design view, double-click the button on your page. Web Matrix switches to Code view, and you ll see the following code:

    Sub Button1_Click(sender As Object, e As Event Args End Sub

    This code is the basic outline the skeleton of the button Click event handler. (We ll discuss event handlers in the next section.)

  2. Add the following boldfaced line to the code:

    Sub Button1_Click(sender As Object, e As Event Args     Label1.Text = TextBox1.Text End Sub

    This line of code will take the contents of the TextBox control whose name is (imaginatively enough) TextBox1 and display it as the contents of the Label control called Label1. (I did say this first program wasn t too sophisticated, didn t I?)




Microsoft ASP. NET Web Matrix Starter Kit
Microsoft ASP.NET Web Matrix Starter Kit (Bpg-Other)
ISBN: 0735618569
EAN: 2147483647
Year: 2003
Pages: 169
Authors: Mike Pope

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net