View Single Post
  #3 (permalink)  
Old July 31st, 2008, 05:51 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

Thanks for your reply, Peter, and sorry for the delay in getting back.

I changed the code to:
Code:
  Dim dt As DateTime = DateTime.Now()
        Dim ctlGreeting As Label = 
CType(UpLoginView.FindControl("ctlGreeting"), Label)

        If dt.Hour < 12 Then
            ctlGreeting.Text = "Good morning"
        Else
            If dt.Hour < 18 Then
                ctlGreeting.Text = "Good afternoon"
            Else
                ctlGreeting.Text = "Good evening"
            End If
        End If

but this produced a different error on the 'good morning' line:
Object reference not set to an instance of an object.

However, to eliminate the duplication of ID=Greeting (on the source page), perhaps the label containing the greeting should be moved to some outer container since it's not role-dependent?

Richard
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express
Reply With Quote