Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response.write question

Status
Not open for further replies.
Joined
Feb 8, 2002
Messages
43
Location
US
I have a page that has a textbox and a button (both web controls run at the server). I want the user to enter in a number in the textbox.

Based upon that number, I want the appropriate number of textboxes to appear for the user to enter in information.

In other words, I am trying to programmatically add textboxes (webcontrols) to my web page when a button is pressed. The number of textboxes added could be whatever number is entered into the initial textbox (In theory it could be infinite). How do I add at webcontrols at the bottom of the existing web page from code?

I am leaning toward response.write but I believe that would only create html controls, not web controls. Any Advice?

Thanks.
 
Check into placeholders. The basic idea is to initialize textboxes in codebehind in a loop based on that number, and then add them to the controls collection of a placeholder.

Google Search:
Programmatic textbox placeholder

Should get you going
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Thanks Link,

Now I've run into the problem of creating a "control array" in ASP.NET. I hear there is no such thing. How do I place textboxes with unique names into the placeholder. Most of the examples assume you know how many you will have so they hard code them.

I need the names of my textboxes to be dynamic.

Thanks again.
 
dim txt as textbox
for i = 0 to someNum
txt = new textbox
txt.id = "myTextBox" & i
placeholder.controls.add(txt)
next

just assign id's with the iterator variable tacked onto the end to give them unique ids
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top