How to add control at run time and handle it
-
i have problem, I want to add control at runtime like two checkBox . when i checked first then enable false of second checkedbox. if any friend have answer then send me mail or post message. Thanks sujitvns4u@gmail.com
Sujit
-
i have problem, I want to add control at runtime like two checkBox . when i checked first then enable false of second checkedbox. if any friend have answer then send me mail or post message. Thanks sujitvns4u@gmail.com
Sujit
Hi, Add the controns in design view and hide the second. On the firsts, activate the AutoPostBack property and on the Page_Load change the visibility of the second checking the checked value of the first.
-
Hi, Add the controns in design view and hide the second. On the firsts, activate the AutoPostBack property and on the Page_Load change the visibility of the second checking the checked value of the first.
-
Hi, Add the controns in design view and hide the second. On the firsts, activate the AutoPostBack property and on the Page_Load change the visibility of the second checking the checked value of the first.
Dear friend my question was that i'm adding control at run time not design time then how to handle event of this control. Thanks for reply
Sujit
-
Dear friend my question was that i'm adding control at run time not design time then how to handle event of this control. Thanks for reply
Sujit
Check this out and please reply me.... public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { CheckBox c1 = new CheckBox(); CheckBox c2 = new CheckBox(); c1.ID = "C1"; c2.ID = "C2"; c1.AutoPostBack = true; c2.AutoPostBack = true; Page.Form.Controls.Add(c1); //or Panel1.Controls.Add(c1); Page.Form.Controls.Add(c2); //or Panel1.Controls.Add(c2); c1.CheckedChanged += new EventHandler(c1_CheckedChanged); } private void c1_CheckedChanged(object sender, EventArgs e) { if (((CheckBox)Page.Form.FindControl("C1")).Checked) //Or Panel1.FindControl("C1") { ((CheckBox)Page.Form.FindControl("C2")).Enabled = false; } else { ((CheckBox)Page.Form.FindControl("C2")).Enabled = true ; } } }