In my Site.Master.vb file, I have a custom User object:
Public Class Site
Inherits System.Web.UI.MasterPage
Public Property u as User
Protected Sub Page_Load(ByVal sender as Object, ByVal e as System.EventArgs) Handles Me.Load
u = New User
u.loggedIn = True 'Just as an example
End Class
Now in one of the content pages, I want to be able to see if a user is logged in. I figured if the object u was declared in the Site Master, I could use it in the pages that derive from the Site Master. For example, I want to do:
...
<% If u.loggedIn Then %>
<!-- display some HTML button here, ONLY if the user is logged in -->
<% Else %>
<!-- display something else, if the user is logged out -->
<% End If %>
Is there some other method that allows this to be possible?
Get a reference of the
Page.Master– you will need to cast it to the type of the master page in order to access the custom property.You can do this in a property of your own page for ease of use.