Q
Quentin Huo
Hi:
I have a user control and I want to dynamically create a Label control and
TextBox control when the button "add more author name" is clicked.
I did like this:
1. there is a "PlaceHolder" control "ph" in the user control;
2. create a Label control and TextBox control when in the "add" button
event, like:
Label lblAuthor = new Label();
lblAuthor.Text="Author";
TextBox tbAuthor = new TextBox();
tbAuthor.ID="...";
3. add the controls to the PlaceHolder control "ph":
ph.Controls.Add(lblAuthor);
ph.Controls.Add(tbAuthor);
But it doesn't work, the value that is typed into the new-created TextBox
control cannot be kept by form(the form tag is in the parent page that
includes the user control). When click another button like "save", the value
will be losted. Where is the problem? How to fix it?
Thanks
Q.
I have a user control and I want to dynamically create a Label control and
TextBox control when the button "add more author name" is clicked.
I did like this:
1. there is a "PlaceHolder" control "ph" in the user control;
2. create a Label control and TextBox control when in the "add" button
event, like:
Label lblAuthor = new Label();
lblAuthor.Text="Author";
TextBox tbAuthor = new TextBox();
tbAuthor.ID="...";
3. add the controls to the PlaceHolder control "ph":
ph.Controls.Add(lblAuthor);
ph.Controls.Add(tbAuthor);
But it doesn't work, the value that is typed into the new-created TextBox
control cannot be kept by form(the form tag is in the parent page that
includes the user control). When click another button like "save", the value
will be losted. Where is the problem? How to fix it?
Thanks
Q.