【发布时间】:2014-05-09 09:17:14
【问题描述】:
问题是,每次我回发时,我的变量“值”都不会保留它以前的值,而且字典总是空的。它没有任何以前保存的数据。我怎样才能让它保存数据?
这是代码:
public partial class MyCart : System.Web.UI.Page
{
public Dictionary<string, string> value = new Dictionary<string, string>();
protected void Page_Load(object sender, EventArgs e)
{
TextBox textbox = new TextBox();
textbox.TextChanged += textbox_TextChanged;
textbox.ID = "textbox" + p.IDProduct.ToString();
Button button = new Button();
}
void textbox_TextChanged(object sender, EventArgs e)
{
value.Add(((TextBox)sender).ID, ((TextBox)sender).Text);
}
}
【问题讨论】: