当我在代码项目中遇到一篇文章时,我正在尝试研究控制状态
http://www.codeproject.com/Articles/331981/A-Beginner-s-Tutorial-Understanding-ControlState-i
但在那个例子中,只有“文本”值保持在控制状态,如果我必须同时保持它们怎么办?所以我尝试了这段代码
protected override void OnInit(EventArgs e)
{
Page.RegisterRequiresControlState(this);
base.OnInit(e);
}
protected override object SaveControlState()
{
object[] state = new object[2]; // save the 2 properties
state[0] = Text;
state[1] = Text1;
return state;
}
protected override void LoadControlState(object savedState)
{
object[] state = (object[])savedState;
Text = (string)state[0];
Text1 = (string)state[1];
}
但这似乎不起作用..有人可以帮帮我吗???
提前致谢