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

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » Custom Controls » TextBox 
14.15.2.Smart box (VB)
<%@ 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)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.