ASP.NET - Button-knop

De Button-knop wordt gebruikt om een knop weer te geven.

Button-knop

De Button-knop wordt gebruikt om een knop weer te geven. Een knop kan een submit-knop of een commandoknop zijn, en deze knop behoort tot de submit-knop.

De submit-knop heeft geen commandonaam en wanneer deze wordt ingedrukt, stuurt hij de pagina terug naar de server. U kunt enkele event handlers schrijven om de uitvoering van de actie te controleren wanneer de submit-knop wordt ingedrukt.

command buttons have named names and allow you to create multiple Button controls on the page. You can write some event handlers to control the execution of actions when the command button is clicked.

The properties of the Button control are listed in our Button control reference manual.

The following example demonstrates a simple Button control:

<html>
<body>
<form runat="server">
<asp:Button id="b1" Text="Submit" runat="server" />
</form>
</body>
</html>

Add script

Forms are usually submitted by clicking a button.

In the following example, we declare a TextBox control, a Button control, and a Label control in the .aspx file. When this submit button is clicked, the submit subroutine will be executed. The submit subroutine will write a text to the Label control:

<script runat="server">
Sub submit(sender As Object, e As EventArgs)
lbl1.Text="Your name is " & txt1.Text
End Sub
</script>
<html>
<body>
<form runat="server">
Enter your name:
<asp:TextBox id="txt1" runat="server" />
<asp:Button OnClick="submit" Text="Submit" runat="server" />
<p><asp:Label id="lbl1" runat="server" /></p>
</form>
</body>
</html>

Display this example