dynamically creating textboxes

Hi
i need  sample code for creating textboxs dynamically


i am using following code
but this will create only one textbox!


 Dim tb As New TextBox
 PlaceHolder.Controls.Add(tb)



BasicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
brdrokCommented:
is there a reason why you can't create multiple textboxes dynamically and add 'em into your placeHolder?

dim tb1 as New TextBox
dim tb2 as New TextBox


tb1.Style["Position"] = "Absolute";
tb1.Style["left"] = "175px";
tb1.Style["top"] = "200px"

//do same for tb2

PlaceHolder.Controls.Add(tb1)
PlaceHolder.Controls.Add(tb2)

to specify the location of your newly created textboxes, you'd set the style property of your textboxes.

at least it works like that in C#, not so sure about vb.net but I'd imagine syntax very similiar.

0
 
HavaganCommented:
Er, so create a loop...

For ...
     Dim tb As New TextBox
     PlaceHolder.Controls.Add(tb)
Next

or

While ...
     Dim tb As New TextBox
     PlaceHolder.Controls.Add(tb)
End While

Paul
0
 
BasicAuthor Commented:

i want each time i click a button
a new textbox will add to the placeholder

and please tell me how to get values of those textboxes
0
 
ihenryCommented:
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.