control visibility based on property

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()%>' />

LVL 2
Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Bob LearnedConnect With a Mentor Commented:
    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
 
Bob LearnedCommented:
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
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Oh, it doesn't work with your method either. sigh.
0
 
Bob LearnedCommented:
Try this:

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

Bob
0
 
codeclayConnect With a Mentor Commented:
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
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
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
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
codeclay, how do I declare the control in the codebehind and set the visibility from there?

remember, I'm a noob.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.