I have a web application. On my page ive got this:
<div id="myDiv" runat="server" />
//and a button that will call a method to save my inputs
on code behind i have this :
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!this.IsPostBack)
{
.....
}
LoadForm(); // this will create a textbox with values inside it and a button called change
// into the div .
//when i click the button , it will create a fileupload control
//and add this control into the div
}
my problem is:
when i first click the button change it will change the textbox and the button to an upload control, no problem with this one, but when i click the save button, on load the page will re-pass from the LoadForm() letting my page create a textbox, while i had changed it to an upload file, how can i solve this???
I dont know if i should add more details, or its clear,
thanks in advance
private void LoadForm()
{
....
button.Click += new EventHandler(button_Click);
this.myDiv.Controls.Add(textBox);
this.myDiv.Controls.Add(button);
}
void button_Click(object sender, EventArgs e)
{
...
this.myDiv.Controls.Clear();
this.myDiv.Controls.Add(here will be the fileupload control);
}