Can someone explain this?

  • Thread starter Thread starter klj_mcsd
  • Start date Start date
K

klj_mcsd

Let's say you set

txtlastname1.visible = true

Then

DirectCast(Page.FindControl("txtLastName1"), TextBox).Visible = False


Why when you check txtlastname1.visible it is equal to True?
Can someone please explain? Thanks
 
Watcha-talkin-about-foo?

txtLastName1.Visible = True
DirectCast(Page.FindControl("txtLastName1"), TextBox).Visible = False
Response.Write(txtLastName1.Visible)

Shows up false to me.

Karl
 
Let's say you set

txtlastname1.visible = true

Then

DirectCast(Page.FindControl("txtLastName1"), TextBox).Visible = False


Why when you check txtlastname1.visible it is equal to True?
Can someone please explain? Thanks

I bet you have a typo somewhere. Try this:

Response.Write(txtlastname1.Equal(Page.FindControl("txtLastName1")))

John Saunders
 
Here is what I'm doing
blnShow = true
Sub Show (ByVal blnShow As Boolean)

txtlastname1.visible = blnShow

if txtlastname1.visible = true then
response.write("1")
else
response.write("2")
end if

2 comes up. Why?
 
The problem is with your code...it should be showing 1 (and it is on my
computer)...What value is being passed into the Show() call? What is
blnShow = true? a field declaration? are you just telling us that you are
sure it's true?


Show(false) ' displays 2
Show(true) ' displays 1

if you are doing Show(false) but have a field named blnShow that you are
setting to true, such as :

private blnShow as boolean = true
public sub Page_Load()
Show(false)
end sub

Sub Show(Byval blnShow as boolean)
...
end sub

the local blnShow variable you are declaring in the Show function overrides
the more global blnShow field declared at the top. In other words, you
might be getting confused because you have two variables named the same
thing (bad) at different scopes and it isn't the one you are expecting.

karl
 
Here is what I'm doing
blnShow = true
Sub Show (ByVal blnShow As Boolean)

txtlastname1.visible = blnShow

if txtlastname1.visible = true then
response.write("1")
else
response.write("2")
end if

2 comes up. Why?


Hey, just for fun, could you send us some context? Like:

Sub Page_Load(sender as Object, EventArgs as e)
Dim blnShow as Boolean = True
Show(blnShow)
End Sub

Sub Show (ByVal blnShow As Boolean)

txtlastname1.visible = blnShow

if txtlastname1.visible = true then
response.write("1")
else
response.write("2")
end if
End Sub


What you actually sent us so far looks like it could be VBScript.

John Saunders
 

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