Define page controls in code behind (VB.net) : Code Behind « User Control and Master Page « ASP.Net






Define page controls in code behind (VB.net)

<%@ Page 
    language=VB 
    debug=true 
    src="ControlsInCodeBehind.vb" 
    Inherits="clsControlsInCodeBehind" 
%>
<HTML>
<HEAD>
<TITLE>Inheriting Controls 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>
<asp:label
    id="lblMessage3"
    runat="Server"
/>
<BR><BR>
<asp:textbox
    id="txtSample1"
    runat="Server"
/>
</form>
</BODY>
</HTML>

<%--
Imports System
Public Class clsControlsInCodeBehind
    Inherits System.Web.UI.Page
    Protected WithEvents txtSample1 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 lblMessage3 As _
        System.Web.UI.WebControls.Label
    Private Sub Page_Init(ByVal sender As System.Object, _
        ByVal e As System.EventArgs)
        lblMessage1.Text = "invisible"
        lblMessage1.Visible = False
        lblMessage2.Text = Date.Now
        lblMessage3.Text = "Server Name: " & Server.MachineName
        txtSample1.MaxLength = 30
        txtSample1.Text = "Enter some text!" 
    End Sub
End Class
--%>
           
       








Related examples in the same category

1.User control with code behind (VB.net)