473,486 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
6 2014
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2044
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
0
1087
by: Michel | last post by:
Hi, I have written a custom control, which I use on 2 ASP.NET pages. The strange part of it : on the one page, it is displayed correctly, in the second it is not displayed. When I take a look...
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
2
2403
by: John Holmes | last post by:
I would like to turn on a label control in javascript with the onfocus event of another control by setting the Visible property to true. When I try and reference this label control it says...
2
2295
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
0
2250
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
11
2597
by: -D- | last post by:
How can I turn the visibility of the xml control on or off? <%@ Control Language="c#" AutoEventWireup="false" Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"...
8
3205
by: kevin.vaughan | last post by:
Good Afternoon Everyone, Could someone please explain why I can't set the Subform control Visible attribute to False as below? The statement for the locked attributes work but not for the...
8
3997
by: Doc John | last post by:
I have an MDI container with a child Form which will be visible according to certain events. The problem is that when I set the property Visible to False and then back to True, the Form will be in...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.