How to solve postback in custom sever controls?
<p>I am creating custom server controls.I created a textbox in this used this control in my page.But when page is posted back(postback) the value of textbox gets omitted..I thought of using viewstate  here but m nt getting textbox value .May be m using in wrong way help me plz</p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection;
namespace DNWebComponent {
    [DefaultProperty("Text")]
    [ToolboxData("&lt;{0}:DNTextBox runat=server&gt;&lt;/{0}:DNTextBox&gt;")]
    public class DNTextBox : WebControl, IDNComponent {


        public String _ConnectedField;
        private string _label;
        private TextBox _txtBox;
        private string _connectedField;
        private string _MultiSeekField;
        private string _InputTable;
        public string ControlClientID;

        public DNTextBox() {
            _txtBox = new TextBox();

        }
        [PersistToViewState]

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Text {
            get {
                String s = (String)ViewState["Text"];
                return ((s == null) ? "[" + AspTextBox.Text + "]" : s);
            }

            set {
                ViewState["Text"] = value;
            }
        }


        public DNTextBox(string label)
            : this() {
            this._label = label;
        }

        public String Label {
            get { return _label; }
            set { _label = value; }
        }

        public String ConnectedField {
            get { return _connectedField; }
            set { _connectedField = value; }
        }
        public String MultiSeekField {
            get { return _MultiSeekField; }
            set { _MultiSeekField = value; }
        }
        public String InputTable {
            get { return _InputTable; }
            set { _InputTable = value; }
        }

        public TextBox AspTextBox {
            get { return _txtBox; }
            set { _txtBox = value; }
        }

        public string DivCss { get; set; }

        protected override void RenderContents(HtmlTextWriter output) {
            output.Write("&lt;div class=\"" + DivCss + "\" &gt;");
            output.Write(Text);
            output.Write(_label + ": ");
            _txtBox.RenderControl(output);

            output.Write("&lt;/div&gt;");
        }

        public bool FillControl() {
            return false;
        }
        protected override void LoadViewState(object savedState) {
            base.LoadViewState(savedState);
            PropertyInfo[] properties = GetType().GetProperties();
            foreach (PropertyInfo property in properties) {
                object[] attributes = property.GetCustomAttributes(typeof(PersistToViewState), true);
                if (attributes.Length &gt; 0) {
                    if (ViewState[property.Name] != null)
                        property.SetValue(this, ViewState[property.Name], null);
                }

            }
        }

        protected override object SaveViewState() {
            ViewState["Text"] = AspTextBox.Text;
            //PropertyInfo[] properties = GetType().GetProperties();
            //foreach (PropertyInfo property in properties) {
            //    object[] attributes = property.GetCustomAttributes(typeof(PersistToViewState), true);
            //    if (attributes.Length &gt; 0)
            //        ViewState[property.Name] = property.GetValue(this, null);
            //}

            return base.SaveViewState();
        }


        [AttributeUsage(AttributeTargets.Property)]
        public class PersistToViewState : Attribute {
        }
    }
}
</code></pre>
