召集Button Event

发表于:2007-06-30来源:作者:点击数: 标签:
这里例子将说明如何利用Code-Behind forms召集Button Event %@ Page Inherits=MyCodeBehind Src=cp. vb De bug =True Language= VB % html head titleNew Page 1/title /head body form runat=server asp:button id=btn1 text=Button 1 OnClick=b1_Click runa
这里例子将说明如何利用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

原文转自:http://www.ltesting.net