Hello all! First time posting. :)
I'm a pretty new developer so I'm not well versed in common ASP.NET problems.
As a test, my boss asked me to convert a (not very critical) ASP.NET site from 1.1 to 4.0. Well, it's not extremely difficult and things are going well so far. However, I've hit a small snag. I keep getting a NullReferenceException when I run this code:
Public Property PageTitle() As String
'===========================================================================
'Exposes the PageTitle property of the child control.
'===========================================================================
Get
Return lblPageTitle.Text
End Get
Set(ByVal Value As String)
'TODO: find out why this throws a NullReference exception
lblPageTitle.Text = Value
End Set
End Property
The Value part does have a string attached to it (literally :) but the lblPageTitle just won't set right.
More background if this helps: Before, this web user control had these in the codebehind, but they started throwing errors because they were already declared. Anyways, here they are:
Public Shared lblPageTitle As New Label
Public Shared lblUser As New Label
Public Shared lblLastLogin As New Label
Public Shared lblToday As New Label
Public Shared lblSiteTitle As New Label
Obviously, the New keyword might have helped in this situation somehow, but none of those other labels have caused any trouble.
I've tried doing this but it didn't work:
Dim PageTitle As New Label
PageTitle = TryCast(ucPageHeader.FindControl("lblTitle"), Label)
If Not IsNothing(PageTitle) Then
PageTitle.Text = sb.ToString()
End If
Any ideas?