lnkcat
是类别的链接按钮,lnksubcat
是子类别的链接按钮:
我的问题是,当我点击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);
}
有人建议解决这个问题吗?请!!
谢谢...
答案 0 :(得分:0)
您如何看待这个?
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);
}