views:

74

answers:

1

Hi, I am new to .Net I created textboxed dynamically, But when i clicked on the button, i loss before created data in the textbox. How can i maintain data in the dynamic textbox.

Thanks in advance..

A: 

Try this:

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);
}
Mehdi Golchin