By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,702 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,702 IT Pros & Developers. It's quick & easy.

I'm Missing SAomething Here

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Sorry - that should have said that I am working on an "aspx" page - NOT an
asp page

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
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

Nov 21 '05 #2

P: n/a
I'm wondering if the postback is resetting everything on you?
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uc**************@TK2MSFTNGP14.phx.gbl...
Sorry - that should have said that I am working on an "aspx" page - NOT an
asp page

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
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


Nov 21 '05 #3

P: n/a
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
Nov 21 '05 #4

P: n/a
Interesting - I'll try that

Wayne

"Cor Ligthert" <no************@planet.nl> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
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

Nov 21 '05 #5

P: n/a
Thanks for the response Tony. I wonder the same thing but hiding the
textboxes works fine?

Wayne

"Tony" <To************@msn.com> wrote in message
news:O2***************@TK2MSFTNGP15.phx.gbl...
I'm wondering if the postback is resetting everything on you?
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uc**************@TK2MSFTNGP14.phx.gbl...
Sorry - that should have said that I am working on an "aspx" page - NOT an asp page

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
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



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.