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

Control.visible = true sets the visibility of a control to false

P: n/a
Hi,

I have a loop running on Page_PreRender that sets a number of controls
to invisible based on a set of criteria. Before I do this however, I set all
of the drop down lists to be visible with a straightforward recursive loop.

Now - I'm really muddled by this - why does this:
If TypeOf Ctl Is DropDownList Then
Ctl.Visible = true
End If
Set the control to be INVISIBLE? How is this possible - I put a breakpoint
in at the first of these lines, evaluate ctl.visible, the debugger returns
"true", step forward one line, evaluate ctl.visible, still true, move on to
the third line, and now ctl.visible = false !!!!! How is this possible? Can
someone please help me? For now, I've created a css class called "invisible"
which uses css to set the control to invisible, but the effect isn't the
same and it's going to make the page a whole bunch bigger.
Any ideas?
Nick
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I for one, need more context to solve this one...like seeing more of the
code...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a loop running on Page_PreRender that sets a number of controls
to invisible based on a set of criteria. Before I do this however, I set all of the drop down lists to be visible with a straightforward recursive loop.
Now - I'm really muddled by this - why does this:
If TypeOf Ctl Is DropDownList Then
Ctl.Visible = true
End If
Set the control to be INVISIBLE? How is this possible - I put a breakpoint
in at the first of these lines, evaluate ctl.visible, the debugger returns
"true", step forward one line, evaluate ctl.visible, still true, move on to the third line, and now ctl.visible = false !!!!! How is this possible? Can someone please help me? For now, I've created a css class called "invisible" which uses css to set the control to invisible, but the effect isn't the
same and it's going to make the page a whole bunch bigger.
Any ideas?
Nick

Nov 19 '05 #2

P: n/a
Hi,

The problem occurs in a custom page class here are the relevant
snippets:

Public Class Standard : Inherits System.Web.UI.Page

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
ResolveDivDDLOverlayConflicts()
End Sub

Private Sub ResolveDivDDLOverlayConflicts()
'first set all Drop down lists to visible before performing analysis
For each ctl as Control in me.controls
_RecursivelySetDDLVisibility(Ctl, True)
next
End Sub

Private Sub _RecursivelySetDDLVisibility(ByVal Control as Control, ByVal
Visibility as boolean)
If TypeOf Control is DropDownList then 'Line A
Control.visible = Visibility 'Line B
end if 'Line C
For each SubControl in Control.Controls
_RecursivelySetDDLVisibility(SubControl, Visibility)
next
End Sub

So if I step through this and evaluate Control.Visible on the Line's marked
A,B & C then at A it's marked as true, at B it's marked at true (because B
hasn't yet been run) but at C it evaluates to false! And what's more if I
then in the immediate window I try to set it to true and then evaluate it
it's still false!

Nick

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
I for one, need more context to solve this one...like seeing more of the
code...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set

all
of the drop down lists to be visible with a straightforward recursive

loop.

Now - I'm really muddled by this - why does this:
If TypeOf Ctl Is DropDownList Then
Ctl.Visible = true
End If
Set the control to be INVISIBLE? How is this possible - I put a breakpoint in at the first of these lines, evaluate ctl.visible, the debugger returns "true", step forward one line, evaluate ctl.visible, still true, move on

to
the third line, and now ctl.visible = false !!!!! How is this possible?

Can
someone please help me? For now, I've created a css class called

"invisible"
which uses css to set the control to invisible, but the effect isn't the
same and it's going to make the page a whole bunch bigger.
Any ideas?
Nick


Nov 19 '05 #3

P: n/a
The code works fine for me...

are there shared variables at play?

Have you tried your code with a simple page? I just had a single
dropdownlist inside my form...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message
news:uC**************@tk2msftngp13.phx.gbl...
Hi,

The problem occurs in a custom page class here are the relevant
snippets:

Public Class Standard : Inherits System.Web.UI.Page

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
ResolveDivDDLOverlayConflicts()
End Sub

Private Sub ResolveDivDDLOverlayConflicts()
'first set all Drop down lists to visible before performing analysis
For each ctl as Control in me.controls
_RecursivelySetDDLVisibility(Ctl, True)
next
End Sub

Private Sub _RecursivelySetDDLVisibility(ByVal Control as Control, ByVal
Visibility as boolean)
If TypeOf Control is DropDownList then 'Line A
Control.visible = Visibility 'Line B
end if 'Line C
For each SubControl in Control.Controls
_RecursivelySetDDLVisibility(SubControl, Visibility)
next
End Sub

So if I step through this and evaluate Control.Visible on the Line's marked A,B & C then at A it's marked as true, at B it's marked at true (because B
hasn't yet been run) but at C it evaluates to false! And what's more if I
then in the immediate window I try to set it to true and then evaluate it
it's still false!

Nick

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
I for one, need more context to solve this one...like seeing more of the
code...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message news:Or**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set all
of the drop down lists to be visible with a straightforward recursive

loop.

Now - I'm really muddled by this - why does this:
If TypeOf Ctl Is DropDownList Then
Ctl.Visible = true
End If
Set the control to be INVISIBLE? How is this possible - I put a breakpoint in at the first of these lines, evaluate ctl.visible, the debugger returns "true", step forward one line, evaluate ctl.visible, still true, move
on to
the third line, and now ctl.visible = false !!!!! How is this
possible? Can
someone please help me? For now, I've created a css class called

"invisible"
which uses css to set the control to invisible, but the effect isn't

the same and it's going to make the page a whole bunch bigger.
Any ideas?
Nick



Nov 19 '05 #4

P: n/a
Not sure what you mean when you refer to "shared variables at play" - could
you clarify?

Not as simple as you mentioned - I actually try it with a single user
control on a single page, with a single drop down list and a bunch of text
boxes - I'll try it without the user control.

Any other suggestions?

Nick

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
The code works fine for me...

are there shared variables at play?

Have you tried your code with a simple page? I just had a single
dropdownlist inside my form...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message
news:uC**************@tk2msftngp13.phx.gbl...
Hi,

The problem occurs in a custom page class here are the relevant
snippets:

Public Class Standard : Inherits System.Web.UI.Page

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
ResolveDivDDLOverlayConflicts()
End Sub

Private Sub ResolveDivDDLOverlayConflicts()
'first set all Drop down lists to visible before performing analysis
For each ctl as Control in me.controls
_RecursivelySetDDLVisibility(Ctl, True)
next
End Sub

Private Sub _RecursivelySetDDLVisibility(ByVal Control as Control, ByVal
Visibility as boolean)
If TypeOf Control is DropDownList then 'Line A
Control.visible = Visibility 'Line B
end if 'Line C
For each SubControl in Control.Controls
_RecursivelySetDDLVisibility(SubControl, Visibility)
next
End Sub

So if I step through this and evaluate Control.Visible on the Line's marked
A,B & C then at A it's marked as true, at B it's marked at true (because B
hasn't yet been run) but at C it evaluates to false! And what's more if I then in the immediate window I try to set it to true and then evaluate it it's still false!

Nick

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
I for one, need more context to solve this one...like seeing more of the code...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is

annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message news:Or**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I have a loop running on Page_PreRender that sets a number of

controls
> to invisible based on a set of criteria. Before I do this however, I set all
> of the drop down lists to be visible with a straightforward recursive loop.
>
> Now - I'm really muddled by this - why does this:
> If TypeOf Ctl Is DropDownList Then
> Ctl.Visible = true
> End If
> Set the control to be INVISIBLE? How is this possible - I put a

breakpoint
> in at the first of these lines, evaluate ctl.visible, the debugger

returns
> "true", step forward one line, evaluate ctl.visible, still true,
move on to
> the third line, and now ctl.visible = false !!!!! How is this possible? Can
> someone please help me? For now, I've created a css class called
"invisible"
> which uses css to set the control to invisible, but the effect isn't the > same and it's going to make the page a whole bunch bigger.
> Any ideas?
> Nick
>
>



Nov 19 '05 #5

P: n/a
I mean do you have any variables declared as shared that this code relies
on?
public shared someValue as Control or something where someValue is used in
the code?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
Not sure what you mean when you refer to "shared variables at play" - could you clarify?

Not as simple as you mentioned - I actually try it with a single user
control on a single page, with a single drop down list and a bunch of text
boxes - I'll try it without the user control.

Any other suggestions?

Nick

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
The code works fine for me...

are there shared variables at play?

Have you tried your code with a simple page? I just had a single
dropdownlist inside my form...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message
news:uC**************@tk2msftngp13.phx.gbl...
Hi,

The problem occurs in a custom page class here are the relevant
snippets:

Public Class Standard : Inherits System.Web.UI.Page

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
ResolveDivDDLOverlayConflicts()
End Sub

Private Sub ResolveDivDDLOverlayConflicts()
'first set all Drop down lists to visible before performing analysis For each ctl as Control in me.controls
_RecursivelySetDDLVisibility(Ctl, True)
next
End Sub

Private Sub _RecursivelySetDDLVisibility(ByVal Control as Control, ByVal Visibility as boolean)
If TypeOf Control is DropDownList then 'Line A
Control.visible = Visibility 'Line B
end if 'Line C
For each SubControl in Control.Controls
_RecursivelySetDDLVisibility(SubControl, Visibility)
next
End Sub

So if I step through this and evaluate Control.Visible on the Line's marked
A,B & C then at A it's marked as true, at B it's marked at true (because B hasn't yet been run) but at C it evaluates to false! And what's more
if
I then in the immediate window I try to set it to true and then evaluate it it's still false!

Nick

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
> I for one, need more context to solve this one...like seeing more of the > code...
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is

annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to > come!)
>
>
> "Nick Stansbury" <ni************@sage-removepartners.com> wrote in

message
> news:Or**************@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I have a loop running on Page_PreRender that sets a number of
controls
> > to invisible based on a set of criteria. Before I do this however,
I set
> all
> > of the drop down lists to be visible with a straightforward recursive > loop.
> >
> > Now - I'm really muddled by this - why does this:
> > If TypeOf Ctl Is DropDownList Then
> > Ctl.Visible = true
> > End If
> > Set the control to be INVISIBLE? How is this possible - I put a
breakpoint
> > in at the first of these lines, evaluate ctl.visible, the debugger
returns
> > "true", step forward one line, evaluate ctl.visible, still true,

move
on
> to
> > the third line, and now ctl.visible = false !!!!! How is this

possible?
> Can
> > someone please help me? For now, I've created a css class called
> "invisible"
> > which uses css to set the control to invisible, but the effect

isn't the
> > same and it's going to make the page a whole bunch bigger.
> > Any ideas?
> > Nick
> >
> >
>
>



Nov 19 '05 #6

P: n/a
Hi,

No - nothing like this.

Thanks for your help Karl - I'm going to call this strugle a day and leave
it. If I get to the bottom of it I'll post a solution (and a cause) back
here

Nick
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uO**************@TK2MSFTNGP09.phx.gbl...
I mean do you have any variables declared as shared that this code relies
on?
public shared someValue as Control or something where someValue is used in
the code?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
Not sure what you mean when you refer to "shared variables at play" - could
you clarify?

Not as simple as you mentioned - I actually try it with a single user
control on a single page, with a single drop down list and a bunch of text
boxes - I'll try it without the user control.

Any other suggestions?

Nick

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
The code works fine for me...

are there shared variables at play?

Have you tried your code with a simple page? I just had a single
dropdownlist inside my form...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Nick Stansbury" <ni************@sage-removepartners.com> wrote in message news:uC**************@tk2msftngp13.phx.gbl...
> Hi,
>
> The problem occurs in a custom page class here are the relevant
> snippets:
>
> Public Class Standard : Inherits System.Web.UI.Page
>
> Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
> ResolveDivDDLOverlayConflicts()
> End Sub
>
> Private Sub ResolveDivDDLOverlayConflicts()
> 'first set all Drop down lists to visible before performing analysis > For each ctl as Control in me.controls
> _RecursivelySetDDLVisibility(Ctl, True)
> next
> End Sub
>
> Private Sub _RecursivelySetDDLVisibility(ByVal Control as Control, ByVal > Visibility as boolean)
> If TypeOf Control is DropDownList then 'Line A
> Control.visible = Visibility 'Line B
> end if 'Line C
> For each SubControl in Control.Controls
> _RecursivelySetDDLVisibility(SubControl, Visibility)
> next
> End Sub
>
> So if I step through this and evaluate Control.Visible on the Line's
marked
> A,B & C then at A it's marked as true, at B it's marked at true (because
B
> hasn't yet been run) but at C it evaluates to false! And what's more

if
I
> then in the immediate window I try to set it to true and then evaluate it
> it's still false!
>
> Nick
>
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> > wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
> > I for one, need more context to solve this one...like seeing more
of the
> > code...
> >
> > Karl
> >
> > --
> > MY ASP.Net tutorials
> > http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ

(more to > > come!)
> >
> >
> > "Nick Stansbury" <ni************@sage-removepartners.com> wrote in
message
> > news:Or**************@TK2MSFTNGP09.phx.gbl...
> > > Hi,
> > >
> > > I have a loop running on Page_PreRender that sets a number
of > controls
> > > to invisible based on a set of criteria. Before I do this however,
I set
> > all
> > > of the drop down lists to be visible with a straightforward

recursive
> > loop.
> > >
> > > Now - I'm really muddled by this - why does this:
> > > If TypeOf Ctl Is DropDownList Then
> > > Ctl.Visible = true
> > > End If
> > > Set the control to be INVISIBLE? How is this possible - I put a
> breakpoint
> > > in at the first of these lines, evaluate ctl.visible, the
debugger > returns
> > > "true", step forward one line, evaluate ctl.visible, still true,

move
on
> > to
> > > the third line, and now ctl.visible = false !!!!! How is this
possible?
> > Can
> > > someone please help me? For now, I've created a css class called
> > "invisible"
> > > which uses css to set the control to invisible, but the effect

isn't the
> > > same and it's going to make the page a whole bunch bigger.
> > > Any ideas?
> > > Nick
> > >
> > >
> >
> >
>
>



Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.