Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

control visibility based on property

Posted on 2007-12-03
9
Medium Priority
?
346 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

772 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