动态创建的texbox值如何可见?(在邮寄中丢失)
本文关键字:创建 texbox 何可见 动态 | 更新日期: 2023-09-27 18:22:19
lnkcat
是Category的链接按钮,lnksubcat
是Sub-class:的链接按钮
我的问题是,当我点击lnk_cat
时,会显示相应的标签和文本框。。。但我点击下一个lnk子卡将被删除。。。。我想在占位符上保留这些文本框对应的标签,直到我点击提交:
protected void lnkCat_Click(object sender, EventArgs e)
{
//Panel2.Visible = false;
//Panel1.Visible = true;
Label lblCat = new Label();
lblCat.Text = "Enter new Category: ";
PHcat.Controls.Add(lblCat);
txtCat = new TextBox();
_Cat = txtCat.Text;
PhtxtCat.Controls.Add(txtCat);
Session["Dynalbl"] = lblCat;
Session["Dynatxt"] = txtCat;
}
protected void lnkSubCat_Click(object sender, EventArgs e)
{
//Panel1.Visible = true;
//Panel2.Visible = true;
Label lblSubcat = new Label();
lblSubcat.Text = "Enter new Sub-Category: ";
PHsubCat.Controls.Add(lblSubcat);
txtSubCat = new TextBox();
_SubCat = txtSubCat.Text;
PhtxtSubCat.Controls.Add(txtSubCat);
}
有人能建议解决这个问题吗?请
谢谢。。。
您对此有何看法?
Label lblCat;
Label lblSubcat;
TextBox txtCat, txtSubCat;
protected void lnkCat_Click(object sender, EventArgs e)
{
//Panel2.Visible = false;
//Panel1.Visible = true;
Label lblCat = new Label();
lblCat.Text = "Enter new Category: ";
PHcat.Controls.Add(lblCat);
txtCat = new TextBox();
_Cat = txtCat.Text;
PhtxtCat.Controls.Add(txtCat);
Session["Dynalbl"] = lblCat;
Session["Dynatxt"] = txtCat;
}
protected void lnkSubCat_Click(object sender, EventArgs e)
{
//Panel1.Visible = true;
//Panel2.Visible = true;
lblCat = (Label)Session["Dynalbl"];
txtCat = (TextBox)Session["Dynatax"];
PHsubCat.Controls.Add(lblCat);
PHsubCat.Controls.Add(txtCat);
Label lblSubcat = new Label();
lblSubcat.Text = "Enter new Sub-Category: ";
PHsubCat.Controls.Add(lblSubcat);
txtSubCat = new TextBox();
_SubCat = txtSubCat.Text;
PhtxtSubCat.Controls.Add(txtSubCat);
}