Data in dynamic textbox
I creat开发者_JS百科ed 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.
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);
}
精彩评论