Smart box : 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="C#">
      protected void Page_Load()
      {
        nameSb.LabelText = "Name:";
        addressSb.LabelText = "Address:";
        countrySb.LabelText = "Country:";
        phoneSb.LabelText = "Phone:";
      }
    </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="C#">
  public string LabelText 
  {
    set
    {
      myLabel.Text = value;
    }
  }
  public string Text
  {
    get
    {
      return myTextBox.Text;
    }
  }
</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)