I'm Missing SAomething Here

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I have an asp page with several pairs of labels and textboxes. If the user
takes a specific action, I want to hide all text boxes and labels with IDs
of "Label4" through "Label13". I am using the subroutine below to try to
accomplish this but only the txt boxes age getting hidden? As you can see in
the code, when the loop to hide the labels did not work I manually coded
that and the labels are still visible?

What did I overlook?

====================== Code ======================
Private Sub HideDataFields()

Dim frmCntrl As Control

Dim cntrl As Control

Dim txtbox As System.Web.UI.HtmlControls.HtmlInputText

frmCntrl = Page.FindControl("Form1")

For Each cntrl In frmCntrl.Controls

If TypeOf cntrl Is System.Web.UI.HtmlControls.HtmlInputText Then

'txtbox = cntrl

cntrl.Visible = False

'Response.Write(txtbox.ID & ":" & txtbox.Value & ":" & txtbox.Name & "<br>")

End If

Next

Dim jj As Integer

For Each cntrl In frmCntrl.Controls

For jj = 4 To 13

If cntrl.ID = "Label" + jj Then

cntrl.Visible = False

End If

Next

Next

Label4.Visible = False

Label5.Visible = False

Label6.Visible = False

Label7.Visible = False

Label8.Visible = False

Label9.Visible = False

Label10.Visible = False

Label11.Visible = False

Label12.Visible = False

Label13.Visible = False

Panel2.Visible = False

End Sub
 
Sorry - that should have said that I am working on an "aspx" page - NOT an
asp page

Wayne
 
Wayne,

Funny, two times quickly behind each other.

I wrote this some lines above to a message above to Jason as well who was
doing a webpage as well. Probably the JavaScript background.

Don't use the + to concatinate strings in VBNet. It is not always working as
you expect when there are numbers involved. Use the &
If cntrl.ID = "Label" & jj.ToString Then
I hope this helps,

Cor
 
Interesting - I'll try that

Wayne

Cor Ligthert said:
Wayne,

Funny, two times quickly behind each other.

I wrote this some lines above to a message above to Jason as well who was
doing a webpage as well. Probably the JavaScript background.

Don't use the + to concatinate strings in VBNet. It is not always working as
you expect when there are numbers involved. Use the &
I hope this helps,

Cor
 
Thanks for the response Tony. I wonder the same thing but hiding the
textboxes works fine?

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top