asp:Button action event calls a subroutine : subroutine « Language Basics « ASP.NET Tutorial






<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Java2sPage" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="output" runat="server"></asp:Label>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>


File: Default.aspx.vb


Partial Class Java2sPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        output.Text = String.Empty

        DisplayMessage()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        DisplayMessage()
    End Sub

    Private Sub DisplayMessage()
        Dim i As Integer
        For i = 1 To 4
            output.Text &= "Welcome to my website<br />"
        Next i
    End Sub
End Class








2.6.subroutine
2.6.1.Define and call sub module (function) in asp.net page (VB)
2.6.2.asp:Button action event calls a subroutine
2.6.3.Pass parameters to subroutine (VB.net)