今天就label1保值问题发了三个帖子了,为什么为什么为什么??这到底是为什么?至今无答案
protected System.Web.UI.WebControls.Label Label1;
Label l;
private void Page_Load(object sender, System.EventArgs e)
{
l=new Label();
if(!IsPostBack)
{
Button2_Click(sender,e);
}
Label1.Controls.Add(l);
}
private void Button1_Click(object sender, System.EventArgs e)
{
}
private void Button2_Click(object sender, System.EventArgs e)
{
l.Text="ccccc";
Label1.Controls.Add(l);
}
上面代码运行后首先按下button1,那么label1的值会变成空值,也就是说不能保值,
但如果运行后首先按下button2,然后再按下button1,那么label1的值就不会改变。为什么??
为什么在page_load()里运行Button2_Click(sender,e)和直接点击button的按键结果不一样??
为什么??为什么首先按下button1,label1不能保值??????为什么????
http://community.csdn.net/Expert/topic/3687/3687452.xml?temp=.9913751
http://community.csdn.net/Expert/topic/3688/3688003.xml?temp=.8483698