Results 1 to 3 of 3

Thread: [RESOLVED] Locate Object reference not set?

  1. #1

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Resolved [RESOLVED] Locate Object reference not set?

    HI,

    I keep getting this error -

    "Object reference not set to an instance of an object"

    Does anyone know how to trap the exact error location, or at least get a more informative error message?

    Here is an example of my code where the error seems to be happening but everything looks okay to me
    VB Code:
    1. Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
    2.         Dim sMsg As String = ""
    3.         Try
    4.             If LCase(txtEdit.Text) = "true" Then
    5.                 Response.Redirect("complete.aspx?display=pro_edit")
    6.             End If
    7.  
    8.         Catch ex As Exception
    9.             ' Record any exceptions and exit
    10.             sMsg = "The following exception occurred: Submit<br />" + ex.Message.ToString
    11.         End Try
    12.  
    13.         If sMsg <> "" Then
    14.             Message.Visible = True
    15.             Message.Text = sMsg.ToString
    16.         End If
    17.     End Sub

    Cheers Al

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Re: Locate Object reference not set?

    1) Just set a breakpoint in your code where ever the error is occurring.

    2) Don't use LCase, use txtEdit.Text.ToLower

    3) and change this
    VB Code:
    1. If sMsg <> "" Then
    2.  
    3. [color=red]To this[/color]
    4.  
    5. If sMsg.Length > 0 Then
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Re: Locate Object reference not set?

    Memnoch1207,

    Thanks for that and thanks for the tips

    If I want to lowercase and trim can I call as follows -

    VB Code:
    1. sUsername = Username.Text.Trim.ToLower

    Does this work with the querystring? I'm getting yet another object ref error
    VB Code:
    1. If Request.QueryString("edit").ToLower = "true" And iUserID > 0 Then

    Cheers Al

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width