Results 1 to 4 of 4

Thread: Displaying data on web page, but passed by inherited class...please read 4 more info

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Displaying data on web page, but passed by inherited class...please read 4 more info

    I have a class called ApplesBase:
    VB Code:
    1. Public Class ApplesBase
    2.     Inherits System.Web.UI.Page
    3.  
    4.     Public Sub New()
    5.        Call LinkToApples
    6.     End Sub
    7.  
    8.     Private Sub LinkToApples()
    9.         'code here to do stuff
    10.     End Sub
    11. End Class
    My web pages now inherit from this:
    VB Code:
    1. Public Class EnteringSite
    2.     Inherits ApplesBase
    3.  
    4.     'code for web page
    5. End Class
    Now in the function LinkToApples I want something like:
    VB Code:
    1. Private Sub LinkToApples()
    2.     If NoPermissions Then
    3.        Response.Write "Woof"
    4.     End If
    5. End Sub
    This is not possible to use the response object in this sense, inside an inherited class that is.
    I could I suppose redirect to another page, but I don't want to do this.

    Any ideas?

    Woof

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Displaying data on web page, but passed by inherited class...please read 4 more info

    This is the best I could come up with - placing the code in an ordinary class. I cannot see a single way to get this from an inheriting class...
    VB Code:
    1. Public Class EnteringSite
    2.     Inherits System.Web.UI.Page
    3.  
    4.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.         'Put user code to initialize the page here
    6.         dim NewApplesBaseRef as ApplesBase = new ApplesBase
    7.  
    8.         If not (NewApplesBaseRef is nothing) Then
    9.             Select Case NewApplesBaseRef.PermissionsRetreived
    10.             Case ApplesBase.enumPermissionsRetreived.NoPermissions
    11.                 Response.Write("woof!")
    12.             End Select
    13.  
    14.             NewApplesBaseRef = nothing
    15.         End If
    16.     End Sub
    17. End Class
    18.  
    19.  
    20. Public Class ApplesBase
    21.     Inherits System.Web.UI.Page
    22.  
    23.     Private CurrentPermissions as enumPermissionsRetreived
    24.    
    25.     Public Enum enumPermissionsRetreived
    26.         NoPermissions   =   0
    27.     End Enum
    28.  
    29.     Public ReadOnly Property PermissionsRetreived as enumPermissionsRetreived
    30.     Get
    31.         Return CurrentPermissions
    32.     End Get
    33.     End Property
    34.  
    35.  
    36.     Public Sub New()
    37.        Call LinkToApples
    38.     End Sub
    39.  
    40.     Private Sub LinkToApples()      
    41.         ' Do permissions check / login routine here & return a value.
    42.         CurrentPermissions = enumPermissionsRetreived.NoPermissions
    43.     End Sub
    44. End Class

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Displaying data on web page, but passed by inherited class...please read 4 more info

    Hmmm by your method my main web page would not inherit my base page?

    Woka

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Displaying data on web page, but passed by inherited class...please read 4 more info

    Sorry Woka, I can't see any way to do this using inheritance!!!

    If I use that above & try & grab at the property from ANY overridden methods within the EnteringSite, it doesn't work! Can't think of another way you're going to be able to do this one...

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width