Solved

control visibility based on property

Posted on 2007-12-03
9
340 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 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 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 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 2

Author Closing Comment

by:Starr Duskk
ID: 31412503
thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

806 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