using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;namespace WebTextBox
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:WebCustomTextBox runat=server></{0}:WebCustomTextBox>")]
    public class WebCustomTextBox : WebControl,INamingContainer
    {
        public WebCustomTextBox()
        {
            this.Width = 20;
            this.Height = 100;
        }        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Text
        {
            get
            {
                String s = (String)ViewState["Text"];
                return ((s == null) ? String.Empty : s);
            }
            set
            {
                ViewState["Text"] = value;
            }
        }        private TextBox txt1;
        private TextBox txt2;
        private TextBox txtResult;
        private Button btn;
        private Label lab;
        
        public override ControlCollection Controls
        {
            get
            {
                return base.Controls;
            }
        }        protected override void RenderContents(HtmlTextWriter output)
        {
            output.RenderBeginTag(HtmlTextWriterTag.Table);
            output.RenderBeginTag(HtmlTextWriterTag.Tr);            output.RenderBeginTag(HtmlTextWriterTag.Td);
            txt1.RenderBeginTag(output);
            output.RenderEndTag();            output.RenderBeginTag(HtmlTextWriterTag.Td);
            output.Write("+");
            output.RenderEndTag();            output.RenderBeginTag(HtmlTextWriterTag.Td);
            txt2.RenderBeginTag(output);
            output.RenderEndTag();            output.RenderBeginTag(HtmlTextWriterTag.Td);
            output.Write("=");
            output.RenderEndTag();            output.RenderBeginTag(HtmlTextWriterTag.Td);
            txtResult.RenderBeginTag(output);
            output.RenderEndTag();            output.RenderBeginTag(HtmlTextWriterTag.Td);
            btn.RenderBeginTag(output);
            output.RenderEndTag();            output.RenderEndTag();
            output.RenderEndTag();            base.RenderContents(output);
        }        protected override void CreateChildControls()
        {
            txt1 = new TextBox();
            txt1.ID = "txt1";
            txt1.Width = 50;            txt2 = new TextBox();
            txt2.ID = "txt2";
            txt2.Width = 50;            txtResult = new TextBox();
            txtResult.ID = "txtResult";
            txtResult.Width = 50;            btn = new Button();
            btn.ID = "btn";
            btn.Width = 50;
            btn.Text = "account";
            btn.Click += new EventHandler(btn_Click);            lab = new Label();
            lab.Text = "请在文本框内输入数值类型";
            lab.Visible = false;            this.Controls.Add(txt1);
            this.Controls.Add(txt2);
            this.Controls.Add(txtResult);
            this.Controls.Add(btn);
            this.Controls.Add(lab);
        }        protected void btn_Click(object sender, EventArgs e)
        {
        }
    }
}