Mega Code Archive

 
Categories / ASP.Net Tutorial / Custom Controls
 

Smart box

<%@ 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" />