首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

用户控件的ViewState

2011-12-18 
用户控件的ViewState!做了一个输入框控件:[DefaultProperty( Text )][ToolboxData( {0}:tttttttrunat

用户控件的ViewState!
做了一个输入框控件:
[DefaultProperty( "Text ")]
        [ToolboxData( " <{0}:ttttttt   runat=server> </{0}:ttttttt> ")]
        public   class   ttttttt:   WebControl
        {
                [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;
                        }
                }

                public   ttttttt()
                        :   base(HtmlTextWriterTag.Input)
                {   }

                protected   override   void   AddAttributesToRender(HtmlTextWriter   writer)
                {
                        base.AddAttributesToRender(writer);
                        writer.AddAttribute(HtmlTextWriterAttribute.Type,   "text ");
                        writer.AddAttribute(HtmlTextWriterAttribute.Value,   Text);
                }
=================
可是在后台取不到输入的值!


[解决办法]

if(Page.IsPostBack && Request.Pamas[this.UniqueID]!= null )
{
this.Text = Request.Pamas[this.UniqueID];
}

把这段代码放在OnLoadViewstata之前,
[解决办法]
IPostBackDataHandler

热点排行