私はWebアプリケーションを持っています。ポストバック時に動的に作成されたアップロードファイルを失う
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
}
私の問題は、次のとおりです: 私は、最初のボタンの変更をクリックしたときにそれがテキストボックスとボタンを変更します私はこれを持って後ろにコードに
<div id="myDiv" runat="server" />
//and a button that will call a method to save my inputs
:私のページIVEで はこれを得ましたアップロードコントロール、これに問題はありませんが、保存ボタンをクリックするとLoadForm()からページが読み込まれ、アップロードファイルに変更されたときにテキストボックスが作成されます私はこれを解決する???
私はより多くの詳細を追加する必要がある場合知っている、またはその明確な、あなたはテキストボックスを作成しないよう事前に おかげ
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);
}
Page_Loadイベントとボタンクリックイベントのコードを投稿できますか?十分なコードがなければ、推測することしかできませんが、LoadFormが!this.IsPostBackブロック内にある必要があるようです。 – fizch
私のloadformを!ispostback becozの中に置くことはできません。私のボタンを動的に作成し、イベントハンドラをボタンに追加しています。loadformから渡さないと、イベントはbecozのボタンを再作成しません。私はいくつかのコードで私の質問を編集します – Grace