Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

control visibility based on property

Posted on 2007-12-03
9
Medium Priority
?
344 Views
Last Modified: 2010-04-21
I have declared and set a property value in my pre_init of my masterpage.

Based on the value of true or false, I want to display a control:

<uc:BannerAd ID="Banner1" runat="server" Visible='<%# NOT Me.IsPrem()%>' />

If the return value is false, it should display the banner in the above.

Here is my property called and set from the pre_init.

    Public Property IsPrem() As Boolean
        Get
            Return IsPremium
        End Get
        Set(ByVal value As Boolean)
            If value = Nothing Then _
                value = False
            If Not Boolean.Equals(isPremium, value) Then
                isPremium = value
            End If
        End Set
    End Property

How do I set this control to use that value?

isPremium is set at the top... and redefined in the pre_init...

Dim isPremium As Boolean = False

the pre_init then calls to set it:
Me.IsPrem = isPremium

<uc:BannerAd ID="Banner1" runat="server" Visible='<%# NOT Me.IsPrem()%>' />

0
Comment
Question by:Starr Duskk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20402991
First, all that work in the setter doesn't provide any value:

    Public Property IsPrem() As Boolean
        Get
            Return IsPremium
        End Get
        Set(ByVal value As Boolean)
            isPremium = value
        End Set
    End Property

Secondly, did it work as you layed it out?

Bob
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20403043
No, mine did not work. It didn't seem to call the function at all.

Do you think it will work if I change it to your method?
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20403051
Oh, it doesn't work with your method either. sigh.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 20403119
Try this:

<uc:BannerAd ID="Banner1" runat="server" Visible='<%= NOT Me.IsPrem %>' />

Bob
0
 
LVL 9

Assisted Solution

by:codeclay
codeclay earned 400 total points
ID: 20403162
Im sure Bob's solution will work . Just a suggestion, why dont you declare the control in the codebehind and set the visibility of the use control from there? It might be much more easier to debug .
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20403291
Parser Error Message: Cannot create an object of type 'System.Boolean' from its string representation '<%= NOT Me.IsPrem %>' for the 'Visible' property.

<uc:BannerAdvfn ID="Banner1" runat="server" Visible='<%= NOT Me.IsPrem %>' />
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20403296
codeclay, how do I declare the control in the codebehind and set the visibility from there?

remember, I'm a noob.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1600 total points
ID: 20403348
    Public Property IsPrem() As Boolean
        Get
            Return IsPremium
        End Get
        Set(ByVal value As Boolean)
            isPremium = value
            Me.Banner1.Visible = Not value
        End Set
    End Property

Bob
0
 
LVL 2

Author Closing Comment

by:Starr Duskk
ID: 31412503
thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question