
Object reference not set to an instance of an object
Thanks, I'll remember that in future.
But the problem was with -
Dim FileURL As String = "c:\inetpub\wwwroot\GMFileUpload\GMDownload\" &
FileList.SelectedItem.Text
Response.WriteFile(FileURL)
I added the try - catch in an attempt to see what was going on.
I couldn't figure out was I was doing wrong.
The penny finally dropped. I "wasn't" doing anything wrong
I was loading the listbox dynamically on the page_load event.
Eventually I discovered - that was too late,
The items showed on the page but weren't really there..... (figure that one
out)
When I moved the list populate routine to the page_init event everything
worked great.
What can I say... Timing is everything.......
You can't use Err.Description
Try
Catch ex as Exception
Response.Write("<script>" & vbCrLf)
Response.Write("alert('" & ex.tostring & "');" & vbCrLf)
Response.Write("</script>" & vbCrLf)
HELLLP!
OK I give up, what am I not doing?
I have a web form with a listbox populated with the files from a folder.
When the user clicks a file then a button the file should begin downloading.
(I should mention I'm new to this web stuff)
Here's what I'm trying:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Try
Dim FileURL As String = "c:\inetpub\wwwroot\GMFileUpload\GMDownload\" &
FileList.SelectedItem.Text
Response.WriteFile(FileURL)
Catch
Response.Write("<script>" & vbCrLf)
Response.Write("alert('" & Err.Description & "');" & vbCrLf)
Response.Write("</script>" & vbCrLf)
End Try
End Sub
this spits back the error : "Object reference not set to an instance of an
object"
I had thought the server end isn't getting the selection, but if I set
autopostback on the listbox to true
the form refreshes and I loose the selection...
I'm sure it's an easy thing, but I can't figure it out without a few
pointers....
Jim