View Single Post
  #1 (permalink)  
Old July 24th, 2008, 09:07 AM
Rich57 Rich57 is offline
Authorized User
 
Join Date: Sep 2007
Location: Rugeley, , United Kingdom.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB: Time-dependent greeting

I am specifying the introductory message text on my Update.aspx page according to role and I want to include an optional "good morning", "good afternoon", "good evening" greeting. I have defined a label control in the content template, and some tests in the code-behind file determine which greeting to use. However, the error "Name 'Greeting' is not declared" has popped up, and I don't know how to fix it.

An extract of my page source is here:

Code:
    <asp:loginview ID="UpLoginView" runat="server">
        <rolegroups>
            <asp:rolegroup Roles="leaders">
                <contenttemplate>
                    <p><asp:label ID="Greeting" runat="server" />
                    <asp:loginname ID="GreetingName" runat="server" />
                    Here you can enter details of a new event, 
or modify details already entered, so long as the event hasn't 
happened already!</p>
            </contenttemplate>
            </asp:rolegroup>
            <asp:rolegroup Roles="administrators">
                <contenttemplate>
                    <p>Welcome back
                    <asp:loginname ID="GreetingName" runat="server" />
                    Here you can enter details of a new event,
 or modify details of future events, or delete events!
</p></contenttemplate>
            </asp:rolegroup>
        </rolegroups>
        <anonymoustemplate>
            This is the anonymous template.
        </anonymoustemplate>
        <loggedintemplate>
            This is the logged in template.
        </loggedintemplate>
    </asp:loginview>
The code-behind is here:

Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
 System.EventArgs) Handles Me.Load
        Dim dt As DateTime = DateTime.Now()

        If dt.Hour < 12 Then
            Greeting.Text = "Good morning"
        Else
            If dt.Hour < 18 Then
                Greeting.Text = "Good afternoon"
            Else
                Greeting.Text = "Good evening"
            End If
        End If
    End Sub
Richard
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express
__________________
Richard
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express
Reply With Quote