用户控件的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