S
samneefs
I'm wondering if there's a way to create an array of textboxes, or loop
through textboxes. The textboxes are in an ASP.NET page, but the
looping happens through Visual Basic.
On page load, textboxes are dynamically created like this:
While Not rs.eof
Response.Write("<tr><td><input type='text' name='article'" &
numberOfRows & "' value='0'></td></tr>")
numberOfRows += 1
rs.movenext()
End While
Next, when you hit a button ("Order"), I want to check which of these
textboxes has a value different than 0.
The goal is to allow people to order a certain number of items (a
simple webshop, basically).
A possible way to do this:
Dim i As Integer, txt As String
For i = 0 To numberOfRows
txt = "article" & i
If txt.value <> "0" Then
Session.Contents("product" & i) = txt.value
End If
Next
So I want to check for each textbox if it contains the value '0', and,
if not, add the number of items you want to a session variable. Of
course, I still need to assign the article code of it too, but that's
for afterwards (unless someone's got a suggestion...). As you can
guess, it doesn't work at all like this. So in this newsgroup I
found something like this:
For Each ctl As Control In Page.Controls
If TypeOf (ctl) Is TextBox And ctl.ID <> "txtaccount" And ctl.ID <>
"txtpaswoord" Then
If ctl <> "0" Then
session.contents(ctl.id) = ctl.value
End If
End If
Next
However, ctl.value etc. doesn't work, either. If anyone has an idea,
please tell. I don't have any idea how to do arrays in asp.net though,
as my knowledge of it is still very limited, so please don't use too
difficult explanations.
Thanks a lot!
through textboxes. The textboxes are in an ASP.NET page, but the
looping happens through Visual Basic.
On page load, textboxes are dynamically created like this:
While Not rs.eof
Response.Write("<tr><td><input type='text' name='article'" &
numberOfRows & "' value='0'></td></tr>")
numberOfRows += 1
rs.movenext()
End While
Next, when you hit a button ("Order"), I want to check which of these
textboxes has a value different than 0.
The goal is to allow people to order a certain number of items (a
simple webshop, basically).
A possible way to do this:
Dim i As Integer, txt As String
For i = 0 To numberOfRows
txt = "article" & i
If txt.value <> "0" Then
Session.Contents("product" & i) = txt.value
End If
Next
So I want to check for each textbox if it contains the value '0', and,
if not, add the number of items you want to a session variable. Of
course, I still need to assign the article code of it too, but that's
for afterwards (unless someone's got a suggestion...). As you can
guess, it doesn't work at all like this. So in this newsgroup I
found something like this:
For Each ctl As Control In Page.Controls
If TypeOf (ctl) Is TextBox And ctl.ID <> "txtaccount" And ctl.ID <>
"txtpaswoord" Then
If ctl <> "0" Then
session.contents(ctl.id) = ctl.value
End If
End If
Next
However, ctl.value etc. doesn't work, either. If anyone has an idea,
please tell. I don't have any idea how to do arrays in asp.net though,
as my knowledge of it is still very limited, so please don't use too
difficult explanations.
Thanks a lot!