Skip navigation.

Starbucks the New McDonald'sAll recent posts"Startup Success" Panel with Guy Kawasaki

Dynamic Text Boxes in Wizard Control

An interesting question was posted in the ASP.NET Forums (How to use dynamically generated TextBox’s in a Wizard): how do you dynamically instantiate a certain number of text boxes in a wizard and collect their values?

I thought it was an interesting challenge, so I put together a sample which prompts how many text entries you want, adds them on the fly and collects what is entered at the end of the wizard “screen” sequence. Sure, it’s not the only way to do it, but, for what it’s worth, feel free to grab source code (C#) and have a look.

As is often the case in ASP.NET, the key to solving this puzzle lies in the order of events.

Comments

Comment permalink 1 jessica |
Thanks for the great sample and the idea for order of events fixing other problems.
Comment permalink 2 nizar |
Hello: thanks for the input. I have been struggling with this like anything. I have a panel on the 8th step and when i reach there i create a table dynamically that has textboxes and dropdowns. As soon as I click next I lose everything. I want to capture the textbox values when I click 'next' but does not happen. The step goes back to the first step and loses every control i created on the 8th step.

In my case the number of textboxes do not change. How can I capture their value once the user clicks the 'next' button.

Is this a similar issue? can you please provide more guidance? Do you also have this code in the vb.net?

this will be a huge help. thanks.
Comment permalink 3 Jerome |
Thanks for the great sample. The one thing I still can't get working is adding the events to the dynamic textboxes? I've tried this in the Page_Load and OnInit events and haven't had any luck. Any thoughts on where to wire up the events for the dynamic controls?

Thanks
Comment permalink 4 Milan Negovan |
You need to do it inside CreateDynamicBoxes(), right after the "box.ID = xxxxx" line, for example.
Comment permalink 5 Ryan |
If you are using 2.0 you can try wiring up the events in OnPreInit

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

TrackBacks

Sorry, TrackBacks are not allowed.

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):