LoadViewState不执行,为什么?
public class CartLoader : System.Web.UI.WebControls.WebControl
{
private string text;
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
protected override void LoadViewState(object savedState)
{
text = savedState.ToString();
}
protected override object SaveViewState()
{
return text;
}
protected override void Render(HtmlTextWriter output)
{
output.Write("<input type= text id='txt_"+ this.UniqueID+"' value='"+Text+"' />");
output.Write("<input type= submit id='" + this.UniqueID + "' value='324' />");
}
}
一个简单的例子,想保存用户输入的值,但页面提交时LoadViewState没执行,所以值没了,怎么让LoadViewState执行??????
------解决方案--------------------
如果你覆盖一个父类方法,例如:
C# code
protected override void abcd(......)
{
base.abcd(.....);
.........
}