前端呼叫後端函數測試




aspx

    <form id="form1" runat="server">
        <div>
            <asp:TextBox ID='TextBox1' runat='server' Text='some word' />
            <asp:label id='Label1' runat='server' text='Label' /><br />
            <asp:Button id='Button1' runat='server' text='Button' />
            <asp:linkbutton id='LinkButton1' runat='server' Text='LinkButton' />
        </div>
    </form>


----------------------------------------------------------------------------------------------------------------
aspx.vb

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Label1.Text = "Button PostBack: " + Me.TextBox1.Text
    End Sub

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Me.Label1.Text = Test("LinkButton PostBack: " + Me.TextBox1.Text)
    End Sub

    Private Function Test(ByVal str As String) As String
        Return str & ", Function(ByVal) and return!"
    End Function

沒有留言:

張貼留言