problem iterating through textboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Elmo Watson

    problem iterating through textboxes

    I have 10 sections on my page - -
    in each section I have 2 textboxes, named similarly (txtIn/txtOut), but
    adding the number to the id - - so it's like txtIn1, txtOut1, txtIn2, etc

    I'm trying to iterate through them and check to see if each has text in
    them:

    Dim iCheck as Integer
    Dim sNum as string
    Dim txtIn As New TextBox
    Dim txtOut As New TextBox


    For iCheck = 1 To 10

    sNum = iCheck.ToString
    txtIn.ID = "txtIn" & sNum
    txtOut.ID = "txtOut" & sNum

    If txtIn.Text <"" Or txtOut.Text <"" Then ' problem here - see below
    ' do processing here
    else
    'whatever
    End If

    Next iCheck

    When debugging, in the 'If' statement, the textbox IDs are correct, but, no
    matter what, they always show "" as the Text property, but they definitely
    do have text - -

    What am I doing wrong





  • Elmo Watson

    #2
    Re: problem iterating through textboxes


    I thought I'd add - - that when I say sections, each section is a row in an
    HTML table and it's all inside an UpdatePanel



    "Elmo Watson" <sm@here.comwro te in message
    news:OJKNZ$zbIH A.4144@TK2MSFTN GP05.phx.gbl...
    >I have 10 sections on my page - -
    in each section I have 2 textboxes, named similarly (txtIn/txtOut), but
    adding the number to the id - - so it's like txtIn1, txtOut1, txtIn2, etc
    >
    I'm trying to iterate through them and check to see if each has text in
    them:
    >
    Dim iCheck as Integer
    Dim sNum as string
    Dim txtIn As New TextBox
    Dim txtOut As New TextBox
    >
    >
    For iCheck = 1 To 10
    >
    sNum = iCheck.ToString
    txtIn.ID = "txtIn" & sNum
    txtOut.ID = "txtOut" & sNum
    >
    If txtIn.Text <"" Or txtOut.Text <"" Then ' problem here - see
    below
    ' do processing here
    else
    'whatever
    End If
    >
    Next iCheck
    >
    When debugging, in the 'If' statement, the textbox IDs are correct, but,
    no matter what, they always show "" as the Text property, but they
    definitely do have text - -
    >
    What am I doing wrong
    >
    >
    >
    >
    >

    Comment

    Working...