Event in code behind file (VB.net)
<%@ Page
language=VB
debug=true
src="EventsInCodeBehind.vb"
Inherits="clsEventsInCodeBehind"
%>
<HTML>
<HEAD>
<TITLE>Inheriting Events in a Code-Behind Files</TITLE>
</HEAD>
<form runat="server">
<BR><BR>
<asp:label
id="lblMessage1"
runat="Server"
/>
<BR><BR>
<asp:label
id="lblMessage2"
runat="Server"
/>
<BR><BR>
Enter text to uppercase:
<BR>
<asp:textbox
id="txtUCase"
runat="Server"
/>
<BR><BR>
Add Numbers:
<BR>
<asp:textbox
id="txtNumber1"
runat="Server"
/>
<BR>
<asp:textbox
id="txtNumber2"
runat="Server"
/>
<asp:button
id="butAdd"
text="Add"
runat="server"
/>
</form>
</BODY>
</HTML>
<%--
Public Class clsEventsInCodeBehind
Inherits System.Web.UI.Page
Protected WithEvents txtUCase As _
System.Web.UI.WebControls.TextBox
Protected WithEvents txtNumber1 As _
System.Web.UI.WebControls.TextBox
Protected WithEvents txtNumber2 As _
System.Web.UI.WebControls.TextBox
Protected WithEvents lblMessage1 As _
System.Web.UI.WebControls.Label
Protected WithEvents lblMessage2 As _
System.Web.UI.WebControls.Label
Protected WithEvents butAdd As _
System.Web.UI.WebControls.Button
Private Sub Page_Init(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
lblMessage1.Text = Date.Now
txtUcase.AutoPostBack = True
End Sub
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
lblMessage2.Text = Date.Now
End Sub
Sub txtUCase_Change(Sender As System.Object, _
E As System.EventArgs) Handles txtUCase.TextChanged
Dim TempString as String
TempString = txtUCase.Text
txtUCase.Text = TempString.ToUpper()
End Sub
Sub butAdd_Click(Sender As System.Object, _
E As System.EventArgs) Handles butAdd.Click
butAdd.Text = CSng(txtNumber1.Text) + CSng(txtNumber2.Text)
End Sub
End Class
--%>
Related examples in the same category