今日准备为textbox添加几个自定义属性,但是自定义属性在页面回发的时候没有保存到对应的状态值

注意,用普通的getset方法并不能保存属性的状态
/// <summary>
/// 扩展textbox的属性,使其增加几个信息字段,方便数据操作
/// </summary>
public class TextBoxExtend:TextBox
{
public string Argument_1
{
get { string s = (string)ViewState["Argument_1"];
return ((s == null) ? string.Empty : s);
}
set { ViewState["Argument_1"] = value; }
}

public string Argument_2
{
get
{
string s = (string)ViewState["Argument_2"];
return ((s == null) ? string.Empty : s);
}
set { ViewState["Argument_2"] = value; }
}

public string Argument_3
{
get
{
string s = (string)ViewState["Argument_3"];
return ((s == null) ? string.Empty : s);
}
set { ViewState["Argument_3"] = value; }
}
}

 

 posted on 2010-11-22 15:36  小鹿  阅读(358)  评论(0编辑  收藏  举报