2009-11-28 41 views
0

我動態創建了文本框,但是當我點擊按鈕時,在文本框中創建數據之前丟失了。我如何維護動態文本框中的數據。動態文本框中的數據

+0

ASP.NET? VB.NET? C#? – MartW 2009-11-28 16:21:09

回答

0

試試這個:

protected void Page_Load(object sender, EventArgs e) 
{ 
    TextBox text = new TextBox() 
    { 
     ID = "TextBox1" 
    }; 

    Button button = new Button() 
    { 
     Text = "Submit" 
    }; 

    button.Click += (s, a) => 
     { 
      text.Text = Request["TextBox1"]; 
     }; 

    PlaceHolder1.Controls.Add(text); 
    PlaceHolder1.Controls.Add(button); 
}