日期:2009-07-07  浏览次数:21062 次

这里例子将说明如何利用Code-Behind forms召集Button Event
<%@ Page Inherits="MyCodeBehind" Src=../../"cp.vb" Debug="True" Language="VB" %>


<HTML>

<head>
<title>New Page 1</title>
</head>

<body>
<form runat="server">
<ASP:button id="btn1" text="Button 1" OnClick="b1_Click" runat="server"/>
<ASP:button id="btn2" text="Button 2" OnClick="b2_Click" runat="server"/>
<ASP:button id="btn3" text="Button 3" OnClick="b3_Click" runat="server"/>
</form>
</body>
</HTML>

cp.vb的代码如下
我将他封装成类
Option Strict Off

Imports System
Imports System.DateTime
Imports System.Globalization
Imports System.Data
Imports System.Data.SQL
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HTMLControls

Public Class MyCodeBehind : Inherits Page
     
    Public Sub B1_Click(Sender As Object, E As EventArgs)
    response.write("B1 was click")
    End Sub
   
    Public Sub B2_Click(Sender As Object, E As EventArgs)
     response.write("B2 was click")
    End Sub


    Public Sub B3_Click(Sender As Object, E As EventArgs)
        response.write("B3<b></b> was click")
    End Sub
End Class