Smart box (VB) : TextBox « Custom Controls « ASP.NET Tutorial






<%@ Register TagPrefix="sp" TagName="SmartBox"
    Src="Control.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>Creating ASP.NET Web Server Controls</title>
    <script runat="server" language="VB">
      Protected Sub Page_Load()
        nameSb.LabelText = "Name:"
        addressSb.LabelText = "Address:"
        countrySb.LabelText = "Country:"
        phoneSb.LabelText = "Phone:"
      End Sub
    </script>
  </head>
  <body>
    <form id="Form1" runat="server">
      <sp:SmartBox id="nameSb" runat="server" LabelText="Name:" />
      <sp:SmartBox id="addressSb" runat="server"
          LabelText="Address:" />
      <sp:SmartBox id="countrySb" runat="server"
          LabelText="Country:" />
      <sp:SmartBox id="phoneSb" runat="server"
          LabelText="Phone:" />
    </form>
  </body>
</html>

File: Control.ascx

<script runat="server" language="VB">
  Public WriteOnly Property LabelText() As String
    Set(ByVal value As String)
      myLabel.Text = value
    End Set
  End Property
  
  Public ReadOnly Property Text() As String
    Get
      Text = myTextBox.Text
    End Get
  End Property
</script>

  <asp:Label ID="myLabel" runat="server" Text="" Width="100" />
  <asp:TextBox ID="myTextBox" runat="server" Text="" Width="200"
      MaxLength="20" />








14.15.TextBox
14.15.1.Smart box
14.15.2.Smart box (VB)