Forum Moderators: open

Message Too Old, No Replies

null reference error

         

jefferson

2:03 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



This is my code

If Not Page.IsPostBack Then
Dim lblFirstName As Label = LoginView1.FindControl("lblFirstName")


If Profile.FirstName <> "" Then
lblFirstName.Text = "Welcome" & Profile.FirstName

Else
lblFirstName.Text = "Welcome"
End If
End If

This is the error:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 14:
Line 15: Else
Line 16: lblFirstName.Text = "Welcome"
Line 17: End If
Line 18: End If

!Please Help!

mrMister

2:19 pm on Jun 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like LoginView1.FindControl("lblFirstName") is returning null

jefferson

2:25 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



This text value of loginview1.lblfirstname is "lblFirstName"

This works fine if using windows authentication.