How to access the <form> control which is in the parent?

Q

Quentin Huo

Hi:

There can be only one <form> control in one page. So generally the user
controls should not include the <form> control.

I created a user control which is used to edit the book's information and I
need to dynamically create the TextBox controls for the author names of a
book because different books have different numbers of the authors ( who
knows how many authors a book has.). I created a TextBox for an author
firstly:

TextBox tb = new TextBox();
tb.ID="authorname";

.......

And I added it to a <asp:Label> control to show it up:

authorsDiv.Controls.Add(tb);



And then I added it to the form control , as

formID.Controls.Add(tb);

Now the problem happened because the form is in the parent of the user
control. So how can I add the dynamically-created TextBox to the <form>
control which is in the user control's parent?

Thanks

Q.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top