Read asp.net textbox text using variable for name in VB.Net code behind -


situation:

i have aspx content page has asp table. in table there 20 rows 1 column. each cell has asp textbox in it.

i have code, vb.net, adds text text box when user clicks button. works fine.

now need do, , can't seem find fits situation exactly, when second button clicked need "loop" through textboxes.

i have hidden label has count of how many text boxes used can set for/next loop. cannot seem figure out how contents of textbox assigned vb variable.

i have code:

for x integer = 1 fcount     tname = "textbox" & x     dim cfilename string = ctype(controls(tname), textbox).tostring()     blah blah blah other code next 

it errors out on line trys assign textbox text variable name tname. latest code have tried. have tried many others can't seem right.

my text boxes named textbox1, textbox2, etc. way textbox20. hidden file counter allows me try , retrieve ones have been used.

any thanked!!

here code tried on computer. structured little differently correct other errors may encounter. more importantly, code works:

  x integer = 1 20      dim tname string = "textbox" & x       if not string.isnullorempty(ctype(controls(tname), textbox).text)         dim cfilename string = ctype(controls(tname), textbox).text      end if   next 

i got rid of fcount based on assumption if textbox5 , textbox10 contained data, fcount 2. if true, loop not correct because trying grab textbox1 , textbox2.

i changed .tostring .text give contents of control.

going error message, controls(tname) must evaluate control on page or error.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -