Solved

control visibility based on property

Posted on 2007-12-03
9
338 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:BobCSD
  • 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 1

Author Comment

by:BobCSD
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 1

Author Comment

by:BobCSD
ID: 20403051
Oh, it doesn't work with your method either. sigh.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20403119
Try this:

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

Bob
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 9

Assisted Solution

by:codeclay
codeclay earned 100 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 1

Author Comment

by:BobCSD
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 1

Author Comment

by:BobCSD
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 400 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 1

Author Closing Comment

by:BobCSD
ID: 31412503
thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now