here is an example of what I am doing
Page Load { //Adds items to a panel (not an updatepanel just a normal panel control) } protected void btnNexMod_Click(object sender, EventArgs e) { // Calls DoWork() and Appends more items to the same panel } My problem is that the asp:button is doing a postback as well as calling DoWork()
Therefore, re-calling my page load, re-initializing my panel :(
I want my items that I have added to the panel to stay there!
All help appreciated, not looking for a hand you the answer kind-of deal. Any steps are appreciated thanks!
Here is an exact example of my problem.
protected void Page_Load(object sender, EventArgs e) { CheckBox chkbox = new CheckBox(); chkbox.Text = "hey"; chkbox.ID = "chk" + "hey"; // Add our checkbox to the panel Panel1.Controls.Add(chkbox); } protected void Button1_Click(object sender, EventArgs e) { CheckBox chkbox = new CheckBox(); chkbox.Text = "hey"; chkbox.ID = "chk" + "hey"; // Add our checkbox to the panel Panel1.Controls.Add(chkbox); } Only thing on the page is a empty panel and a button with this click even handler.
I have also tried this and it still doesn't work. Now its clearing the initial item appended to the panel.
if (!Page.IsPostBack) // to avoid reloading your control on postback { CheckBox chkbox = new CheckBox(); chkbox.Text = "Initial"; chkbox.ID = "chk" + "Initial"; // Add our checkbox to the panel Panel1.Controls.Add(chkbox); }