Here's an illustration of what I'm talking about.
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 issue is that the asp:button performs a postback in addition to calling DoWork ()
As a result, I'm reloading my page and re-initializing my panel:(
I'd like the items I've added on the panel to remain there!
All assistance is very welcomed; but, I am not asking for someone to deliver you the solution. Thank you for taking any measures!
Here's a specific example of my issue.
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 an empty panel and a button with this click even handler are visible on the website.
I've tried this as well, and it still doesn't work. It's now removing the first item that was added 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);
}